Class: Dima::Html::Action
- Inherits:
-
Object
- Object
- Dima::Html::Action
- Includes:
- Init
- Defined in:
- lib/dima/html/action.rb
Instance Attribute Summary collapse
-
#confirm ⇒ Object
Returns the value of attribute confirm.
-
#icon ⇒ Object
Returns the value of attribute icon.
-
#label ⇒ Object
Returns the value of attribute label.
-
#method ⇒ Object
Returns the value of attribute method.
-
#tooltip ⇒ Object
Returns the value of attribute tooltip.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
Methods included from Init
Instance Attribute Details
#confirm ⇒ Object
Returns the value of attribute confirm.
7 8 9 |
# File 'lib/dima/html/action.rb', line 7 def confirm @confirm end |
#icon ⇒ Object
Returns the value of attribute icon.
5 6 7 |
# File 'lib/dima/html/action.rb', line 5 def icon @icon end |
#label ⇒ Object
Returns the value of attribute label.
5 6 7 |
# File 'lib/dima/html/action.rb', line 5 def label @label end |
#method ⇒ Object
Returns the value of attribute method.
8 9 10 |
# File 'lib/dima/html/action.rb', line 8 def method @method end |
#tooltip ⇒ Object
Returns the value of attribute tooltip.
6 7 8 |
# File 'lib/dima/html/action.rb', line 6 def tooltip @tooltip end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/dima/html/action.rb', line 5 def url @url end |
Instance Method Details
#to_n(val = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/dima/html/action.rb', line 10 def to_n(val = nil) href = url.is_a?(Proc) ? url.call(val) : url text = label.is_a?(Proc) ? url.call(val) : label n = Dima::Html::Node.new(tag: 'a', attributes: { class: 'dim-action', href: href, title: tooltip }) n['data-confirm'] = self.confirm if self.confirm n['data-method'] = self.method if self.method n << Dima::Html::Node.new(tag: 'img', attributes: { src: icon }) if icon n << Dima::Html::Node.new(tag: 'span', text: text ) n end |