Class: Transit::TaggedValue
- Inherits:
-
Object
- Object
- Transit::TaggedValue
- Defined in:
- lib/transit/transit_types.rb
Overview
Represents a transit tag and value. Returned by default when a reader encounters a tag for which there is no registered handler. Can also be used in a custom write handler to force representation to use a transit ground type using a rep for which there is no registered handler (e.g., an iterable for the representation of an array).
Instance Attribute Summary collapse
-
#rep ⇒ Object
readonly
Returns the value of attribute rep.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(tag, rep) ⇒ TaggedValue
constructor
A new instance of TaggedValue.
Constructor Details
#initialize(tag, rep) ⇒ TaggedValue
Returns a new instance of TaggedValue.
244 245 246 247 |
# File 'lib/transit/transit_types.rb', line 244 def initialize(tag, rep) @tag = tag @rep = rep end |
Instance Attribute Details
#rep ⇒ Object (readonly)
Returns the value of attribute rep.
243 244 245 |
# File 'lib/transit/transit_types.rb', line 243 def rep @rep end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
243 244 245 |
# File 'lib/transit/transit_types.rb', line 243 def tag @tag end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
249 250 251 |
# File 'lib/transit/transit_types.rb', line 249 def ==(other) other.is_a?(self.class) && other.tag == @tag && other.rep == @rep end |
#hash ⇒ Object
254 255 256 |
# File 'lib/transit/transit_types.rb', line 254 def hash @tag.hash + @rep.hash end |