Class: Rubyfocus::SearchableArray
- Inherits:
-
Object
- Object
- Rubyfocus::SearchableArray
- Includes:
- Searchable
- Defined in:
- lib/rubyfocus/includes/searchable.rb
Overview
A sample class, SearchableArray, is basically a wrapper around a standard array
Instance Attribute Summary collapse
-
#array ⇒ Object
readonly
Returns the value of attribute array.
Instance Method Summary collapse
-
#initialize(*args, &blck) ⇒ SearchableArray
constructor
Takes the same arguments as the array it wraps.
-
#method_missing(meth, *args, &blck) ⇒ Object
In all other respects, it’s an array - handily governed by this method.
Methods included from Searchable
Constructor Details
#initialize(*args, &blck) ⇒ SearchableArray
Takes the same arguments as the array it wraps
70 71 72 |
# File 'lib/rubyfocus/includes/searchable.rb', line 70 def initialize(*args, &blck) @array = Array.new(*args, &blck) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &blck) ⇒ Object
In all other respects, it’s an array - handily governed by this method
75 76 77 78 79 80 81 |
# File 'lib/rubyfocus/includes/searchable.rb', line 75 def method_missing meth, *args, &blck if @array.respond_to?(meth) @array.send(meth, *args, &blck) else super(meth, *args, &blck) end end |
Instance Attribute Details
#array ⇒ Object (readonly)
Returns the value of attribute array.
67 68 69 |
# File 'lib/rubyfocus/includes/searchable.rb', line 67 def array @array end |