Class: TicketTag
- Inherits:
-
Object
- Object
- TicketTag
- Defined in:
- app/models/ticket_tag.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, color) ⇒ TicketTag
constructor
A new instance of TicketTag.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, color) ⇒ TicketTag
Returns a new instance of TicketTag.
3 4 5 6 |
# File 'app/models/ticket_tag.rb', line 3 def initialize(name, color) @name = name @color = color end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
8 9 10 |
# File 'app/models/ticket_tag.rb', line 8 def color @color end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'app/models/ticket_tag.rb', line 8 def name @name end |
Class Method Details
.from_s(string) ⇒ Object
10 11 12 13 14 15 |
# File 'app/models/ticket_tag.rb', line 10 def self.from_s(string) name, color = string.scan(/\[([^\]]+)\]\(([a-fA-F0-9]{6})\)/).flatten name = string unless name color = "e4e4e4" unless color new(name, color) end |
Instance Method Details
#to_h ⇒ Object
21 22 23 |
# File 'app/models/ticket_tag.rb', line 21 def to_h {name: name, color: color} end |
#to_s ⇒ Object
17 18 19 |
# File 'app/models/ticket_tag.rb', line 17 def to_s "[#{name}](#{color})" end |