Class: RailsOmnibar::Item::Base
- Inherits:
-
Object
- Object
- RailsOmnibar::Item::Base
- Defined in:
- lib/rails_omnibar/item/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#modal_html ⇒ Object
readonly
Returns the value of attribute modal_html.
-
#suggested ⇒ Object
readonly
Returns the value of attribute suggested.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(title:, url: nil, icon: nil, modal_html: nil, suggested: false, type: :default) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(title:, url: nil, icon: nil, modal_html: nil, suggested: false, type: :default) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/rails_omnibar/item/base.rb', line 6 def initialize(title:, url: nil, icon: nil, modal_html: nil, suggested: false, type: :default) url.present? && modal_html.present? && raise(ArgumentError, 'use EITHER url: OR modal_html:') @title = validate_title(title) @url = url @icon = validate_icon(icon) @modal_html = modal_html @suggested = !!suggested @type = type end |
Instance Attribute Details
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
4 5 6 |
# File 'lib/rails_omnibar/item/base.rb', line 4 def icon @icon end |
#modal_html ⇒ Object (readonly)
Returns the value of attribute modal_html.
4 5 6 |
# File 'lib/rails_omnibar/item/base.rb', line 4 def modal_html @modal_html end |
#suggested ⇒ Object (readonly)
Returns the value of attribute suggested.
4 5 6 |
# File 'lib/rails_omnibar/item/base.rb', line 4 def suggested @suggested end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'lib/rails_omnibar/item/base.rb', line 4 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/rails_omnibar/item/base.rb', line 4 def type @type end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/rails_omnibar/item/base.rb', line 4 def url @url end |
Instance Method Details
#as_json ⇒ Object
17 18 19 |
# File 'lib/rails_omnibar/item/base.rb', line 17 def as_json(*) { title: title, url: url, icon: icon, modalHTML: modal_html, suggested: suggested, type: type } end |