Class: Rerout::Models::TagSummary
- Inherits:
-
Object
- Object
- Rerout::Models::TagSummary
- Defined in:
- lib/rerout/models.rb
Overview
A tag with the number of live (non-deleted) links it is attached to —‘{ id:, name:, color:, link_count: }`. Returned by `tags.list`; the create/update responses use the plain Tag (no `link_count`).
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#link_count ⇒ Object
readonly
Returns the value of attribute link_count.
-
#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:, link_count:) ⇒ TagSummary
constructor
A new instance of TagSummary.
- #to_h ⇒ Object
Constructor Details
#initialize(id:, name:, color:, link_count:) ⇒ TagSummary
Returns a new instance of TagSummary.
44 45 46 47 48 49 50 |
# File 'lib/rerout/models.rb', line 44 def initialize(id:, name:, color:, link_count:) @id = id @name = name @color = color @link_count = link_count freeze end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
42 43 44 |
# File 'lib/rerout/models.rb', line 42 def color @color end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
42 43 44 |
# File 'lib/rerout/models.rb', line 42 def id @id end |
#link_count ⇒ Object (readonly)
Returns the value of attribute link_count.
42 43 44 |
# File 'lib/rerout/models.rb', line 42 def link_count @link_count end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
42 43 44 |
# File 'lib/rerout/models.rb', line 42 def name @name end |
Class Method Details
.from_hash(hash) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/rerout/models.rb', line 52 def self.from_hash(hash) new( id: hash['id'], name: hash['name'], color: hash['color'], link_count: hash.fetch('link_count', 0) ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
65 66 67 |
# File 'lib/rerout/models.rb', line 65 def ==(other) other.is_a?(TagSummary) && other.to_h == to_h end |
#hash ⇒ Object
70 71 72 |
# File 'lib/rerout/models.rb', line 70 def hash [self.class, id, name, color, link_count].hash end |
#to_h ⇒ Object
61 62 63 |
# File 'lib/rerout/models.rb', line 61 def to_h { id: id, name: name, color: color, link_count: link_count } end |