Class: Namo::Row
- Inherits:
-
Object
- Object
- Namo::Row
- Defined in:
- lib/Namo/Row.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](name, *arguments) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
- #match?(selections) ⇒ Boolean
- #to_h ⇒ Object
Instance Method Details
#==(other) ⇒ Object
15 16 17 |
# File 'lib/Namo/Row.rb', line 15 def ==(other) other.is_a?(Row) && @row == other.to_h end |
#[](name, *arguments) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/Namo/Row.rb', line 6 def [](name, *arguments) raise_unless_expected_arguments(name, arguments) if @formulae.key?(name) @formulae.derive(name, self, @namo, *arguments) else @row[name] end end |
#eql?(other) ⇒ Boolean
19 20 21 |
# File 'lib/Namo/Row.rb', line 19 def eql?(other) other.is_a?(Row) && @row.eql?(other.to_h) end |
#hash ⇒ Object
23 24 25 |
# File 'lib/Namo/Row.rb', line 23 def hash @row.hash end |
#match?(selections) ⇒ Boolean
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/Namo/Row.rb', line 27 def match?(selections) selections.all? do |dimension, coordinate| case coordinate when Array, Range coordinate.include?(self[dimension]) when Proc coordinate.call(self[dimension]) when Regexp coordinate.match?(self[dimension].to_s) else self[dimension] == coordinate end end end |
#to_h ⇒ Object
42 43 44 |
# File 'lib/Namo/Row.rb', line 42 def to_h @row end |