Class: HashtagAutocompleteService::HashtagItem
- Inherits:
-
Object
- Object
- HashtagAutocompleteService::HashtagItem
- Defined in:
- app/services/hashtag_autocomplete_service.rb
Instance Attribute Summary collapse
-
#colors ⇒ Object
The colors to use when displaying the symbol/icon for the hashtag, e.g.
-
#description ⇒ Object
The description text to display in the UI autocomplete menu on hover.
-
#icon ⇒ Object
The icon to display in the UI autocomplete menu for the item.
-
#id ⇒ Object
The ID of the resource that is represented by the autocomplete item, e.g.
-
#ref ⇒ Object
Inserted into the textbox when an autocomplete item is selected, and must be unique so it can be used for lookups via the #lookup method above.
-
#relative_url ⇒ Object
The relative URL for the resource that is represented by the autocomplete item, used for the cooked hashtags, e.g.
-
#secondary_text ⇒ Object
Some items may want to display extra text in the UI styled differently, e.g.
-
#slug ⇒ Object
Canonical slug for the item.
-
#text ⇒ Object
The text to display in the UI autocomplete menu for the item.
-
#type ⇒ Object
Distinguishes between different entities e.g.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ HashtagItem
constructor
A new instance of HashtagItem.
- #to_h ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ HashtagItem
Returns a new instance of HashtagItem.
107 108 109 110 111 112 113 114 115 116 117 |
# File 'app/services/hashtag_autocomplete_service.rb', line 107 def initialize(params = {}) @relative_url = params[:relative_url] @text = params[:text] @description = params[:description] @icon = params[:icon] @colors = params[:colors] @type = params[:type] @ref = params[:ref] @slug = params[:slug] @id = params[:id] end |
Instance Attribute Details
#colors ⇒ Object
The colors to use when displaying the symbol/icon for the hashtag, e.g. category badge
89 90 91 |
# File 'app/services/hashtag_autocomplete_service.rb', line 89 def colors @colors end |
#description ⇒ Object
The description text to display in the UI autocomplete menu on hover. This will be things like e.g. category description.
79 80 81 |
# File 'app/services/hashtag_autocomplete_service.rb', line 79 def description @description end |
#icon ⇒ Object
The icon to display in the UI autocomplete menu for the item.
86 87 88 |
# File 'app/services/hashtag_autocomplete_service.rb', line 86 def icon @icon end |
#id ⇒ Object
The ID of the resource that is represented by the autocomplete item, e.g. category.id, tag.id
105 106 107 |
# File 'app/services/hashtag_autocomplete_service.rb', line 105 def id @id end |
#ref ⇒ Object
Inserted into the textbox when an autocomplete item is selected, and must be unique so it can be used for lookups via the #lookup method above.
97 98 99 |
# File 'app/services/hashtag_autocomplete_service.rb', line 97 def ref @ref end |
#relative_url ⇒ Object
The relative URL for the resource that is represented by the autocomplete item, used for the cooked hashtags, e.g. /c/2/staff
101 102 103 |
# File 'app/services/hashtag_autocomplete_service.rb', line 101 def relative_url @relative_url end |
#secondary_text ⇒ Object
Some items may want to display extra text in the UI styled differently, e.g. tag topic counts.
75 76 77 |
# File 'app/services/hashtag_autocomplete_service.rb', line 75 def secondary_text @secondary_text end |
#slug ⇒ Object
Canonical slug for the item. Different from the ref, which can have the type as a suffix to distinguish between conflicts.
83 84 85 |
# File 'app/services/hashtag_autocomplete_service.rb', line 83 def slug @slug end |
#text ⇒ Object
The text to display in the UI autocomplete menu for the item.
72 73 74 |
# File 'app/services/hashtag_autocomplete_service.rb', line 72 def text @text end |
#type ⇒ Object
Distinguishes between different entities e.g. tag, category.
92 93 94 |
# File 'app/services/hashtag_autocomplete_service.rb', line 92 def type @type end |
Instance Method Details
#to_h ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'app/services/hashtag_autocomplete_service.rb', line 119 def to_h { relative_url: self.relative_url, text: self.text, description: self.description, icon: self.icon, colors: self.colors, type: self.type, ref: self.ref, slug: self.slug, id: self.id, } end |