Class: YTools::Path::IndexSelector
- Defined in:
- lib/ytools/path/selectors.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Attributes inherited from Selector
Instance Method Summary collapse
-
#initialize(index) ⇒ IndexSelector
constructor
A new instance of IndexSelector.
- #select(array) ⇒ Object
Methods inherited from Selector
Constructor Details
#initialize(index) ⇒ IndexSelector
Returns a new instance of IndexSelector.
48 49 50 |
# File 'lib/ytools/path/selectors.rb', line 48 def initialize(index) @index = index end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
46 47 48 |
# File 'lib/ytools/path/selectors.rb', line 46 def index @index end |
Instance Method Details
#select(array) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ytools/path/selectors.rb', line 52 def select(array) if array.respond_to?(:[]) value = array[index] if chained? subselector.select(value) else value end else nil end end |