Class: Transit::TaggedValue

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#repObject (readonly)

Returns the value of attribute rep.



243
244
245
# File 'lib/transit/transit_types.rb', line 243

def rep
  @rep
end

#tagObject (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

#hashObject



254
255
256
# File 'lib/transit/transit_types.rb', line 254

def hash
  @tag.hash + @rep.hash
end