Class: Quik::Catalog
- Inherits:
-
Object
- Object
- Quik::Catalog
- Defined in:
- lib/quik/catalog.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(text) ⇒ Catalog
constructor
A new instance of Catalog.
- #list(filter = nil) ⇒ Object
Constructor Details
#initialize(text) ⇒ Catalog
Returns a new instance of Catalog.
24 25 26 |
# File 'lib/quik/catalog.rb', line 24 def initialize( text ) @scripts = YAML.load( text ) end |
Class Method Details
.from_file(path) ⇒ Object
13 14 15 16 17 |
# File 'lib/quik/catalog.rb', line 13 def self.from_file( path ) ## read in themes catalog text = File.read( path ) ## fix: use File.read_utf8 ?? self.from_string( text ) end |
.from_string(text) ⇒ Object
19 20 21 |
# File 'lib/quik/catalog.rb', line 19 def self.from_string( text ) self.new( text ) end |
.from_url(src) ⇒ Object
7 8 9 10 11 |
# File 'lib/quik/catalog.rb', line 7 def self.from_url( src ) worker = Fetcher::Worker.new text = worker.read_utf8!( src ) self.from_string( text ) end |
Instance Method Details
#list(filter = nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/quik/catalog.rb', line 28 def list( filter=nil ) ## pp filter @scripts.each_with_index do |h,i| name = h['name'] summary = h['summary'] line = '' line << " %3d" % (i+1) line << "..%-10s" % name line << " .:. #{summary}" if filter ## note: ignore case (upper/lower/downcase) for now ## filter on name/title and ## tags for now if name.downcase.index(filter.downcase) != nil || ## note: 0 is match found on index 0; only nil is not found summary.downcase.index(filter.downcase) != nil puts line end else puts line end end end |