class Mooncats::DesignSeries
todo/check:
find a better way to (auto?) include more designs?
Public Class Methods
build( dir )
click to toggle source
# File lib/mooncats/design.rb, line 101 def self.build( dir ) data = {} paths = Dir.glob( "#{dir}/**.txt" ) paths.each do |path| basename = File.basename( path, File.extname( path ) ) num = basename.to_i( 10 ) ## use base 10 (e.g. 001 => 1, 002 => 2, etc.) text = File.open( path, 'r:utf-8' ) { |f| f.read } ## todo/check: auto-parse "ahead of time" here ## or keep "raw" text - why? why not? data[ num ] = text end data end
new( dir )
click to toggle source
# File lib/mooncats/design.rb, line 115 def initialize( dir ) @dir = dir # e.g. "#{Mooncats.root}/config/v2" end
Public Instance Methods
[](index)
click to toggle source
# File lib/mooncats/design.rb, line 124 def [](index) data[ index ]; end
data()
click to toggle source
# File lib/mooncats/design.rb, line 119 def data ## note: lazy load / build on first demand only @data ||= self.class.build( @dir ) end
size()
click to toggle source
# File lib/mooncats/design.rb, line 125 def size() data.size; end