Class: Rerout::Models::Tag
- Inherits:
-
Object
- Object
- Rerout::Models::Tag
- Defined in:
- lib/rerout/models.rb
Overview
A label attached to a link — ‘{ id:, name:, color: }`. Read-only; the API ignores tag writes for API-key clients.
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(id:, name:, color:) ⇒ Tag
constructor
A new instance of Tag.
- #to_h ⇒ Object
Constructor Details
#initialize(id:, name:, color:) ⇒ Tag
Returns a new instance of Tag.
13 14 15 16 17 18 |
# File 'lib/rerout/models.rb', line 13 def initialize(id:, name:, color:) @id = id @name = name @color = color freeze end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
11 12 13 |
# File 'lib/rerout/models.rb', line 11 def color @color end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/rerout/models.rb', line 11 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/rerout/models.rb', line 11 def name @name end |
Class Method Details
.from_hash(hash) ⇒ Object
20 21 22 |
# File 'lib/rerout/models.rb', line 20 def self.from_hash(hash) new(id: hash['id'], name: hash['name'], color: hash['color']) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
28 29 30 |
# File 'lib/rerout/models.rb', line 28 def ==(other) other.is_a?(Tag) && other.id == id && other.name == name && other.color == color end |
#hash ⇒ Object
33 34 35 |
# File 'lib/rerout/models.rb', line 33 def hash [self.class, id, name, color].hash end |
#to_h ⇒ Object
24 25 26 |
# File 'lib/rerout/models.rb', line 24 def to_h { id: id, name: name, color: color } end |