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.
237 238 239 240 |
# File 'lib/transit/transit_types.rb', line 237 def initialize(tag, rep) @tag = tag @rep = rep end |
Instance Attribute Details
#rep ⇒ Object (readonly)
Returns the value of attribute rep.
236 237 238 |
# File 'lib/transit/transit_types.rb', line 236 def rep @rep end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
236 237 238 |
# File 'lib/transit/transit_types.rb', line 236 def tag @tag end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
242 243 244 |
# File 'lib/transit/transit_types.rb', line 242 def ==(other) other.is_a?(self.class) && other.tag == @tag && other.rep == @rep end |
#hash ⇒ Object
247 248 249 |
# File 'lib/transit/transit_types.rb', line 247 def hash @tag.hash + @rep.hash end |