Class: Mjai::Mentsu
- Inherits:
-
Object
- Object
- Mjai::Mentsu
- Extended by:
- WithFields
- Includes:
- Comparable
- Defined in:
- lib/mjai/mentsu.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Attributes included from WithFields
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(fields) ⇒ Mentsu
constructor
A new instance of Mentsu.
- #inspect ⇒ Object
Methods included from WithFields
Constructor Details
#initialize(fields) ⇒ Mentsu
Returns a new instance of Mentsu.
15 16 17 |
# File 'lib/mjai/mentsu.rb', line 15 def initialize(fields) @fields = fields end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
19 20 21 |
# File 'lib/mjai/mentsu.rb', line 19 def fields @fields end |
Instance Method Details
#<=>(other) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/mjai/mentsu.rb', line 35 def <=>(other) if self.class == other.class return Mentsu.field_names.map(){ |s| @fields[s] } <=> Mentsu.field_names.map(){ |s| other.fields[s] } else raise(ArgumentError, "invalid comparison") end end |
#==(other) ⇒ Object Also known as: eql?
25 26 27 |
# File 'lib/mjai/mentsu.rb', line 25 def ==(other) return self.class == other.class && @fields == other.fields end |
#hash ⇒ Object
31 32 33 |
# File 'lib/mjai/mentsu.rb', line 31 def hash() return @fields.hash() end |
#inspect ⇒ Object
21 22 23 |
# File 'lib/mjai/mentsu.rb', line 21 def inspect return "\#<%p %p>" % [self.class, @fields] end |