Class: IndentedList
- Inherits:
-
Object
- Object
- IndentedList
- Defined in:
- lib/indented-list.rb
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Returns the value of attribute list.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#find(regex) ⇒ Object
Full text search.
-
#get(*params) ⇒ Object
Hook.
-
#initialize(list) ⇒ IndentedList
constructor
A new instance of IndentedList.
- #method_missing(method, *args, &block) ⇒ Object
- #original_respond_to? ⇒ Object
- #respond_to?(method) ⇒ Boolean
Constructor Details
#initialize(list) ⇒ IndentedList
Returns a new instance of IndentedList.
60 61 62 63 |
# File 'lib/indented-list.rb', line 60 def initialize( list ) parser = IndentedListParser.new( list ) @list = parser.list end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
69 70 71 |
# File 'lib/indented-list.rb', line 69 def method_missing( method, *args, &block ) list.respond_to?( method, *args, &block ) ? list.send( method, *args, &block ) : super end |
Instance Attribute Details
#list ⇒ Object (readonly)
Returns the value of attribute list.
58 59 60 |
# File 'lib/indented-list.rb', line 58 def list @list end |
Instance Method Details
#each(&block) ⇒ Object
65 66 67 |
# File 'lib/indented-list.rb', line 65 def each( &block ) list.each( &block ) end |
#find(regex) ⇒ Object
Full text search. Takes a regular expression as an argument. Returns full branch of the root Hash in which match has occured.
82 83 84 |
# File 'lib/indented-list.rb', line 82 def find( regex ) list.select { |k,v| { k => v } if ( k.match( regex ) || v.to_s.match( regex ) ) } end |
#get(*params) ⇒ Object
Hook
89 90 91 |
# File 'lib/indented-list.rb', line 89 def get( *params ) puts 'Implement specific searches for your list. See documentation for how to do this.' end |
#original_respond_to? ⇒ Object
73 |
# File 'lib/indented-list.rb', line 73 alias_method :original_respond_to? , :respond_to? |
#respond_to?(method) ⇒ Boolean
74 75 76 |
# File 'lib/indented-list.rb', line 74 def respond_to?( method ) original_respond_to?( method ) || list.respond_to?( method ) end |