Class: Dima::Html::Action

Inherits:
Object
  • Object
show all
Includes:
Init
Defined in:
lib/dima/html/action.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Init

#initialize

Instance Attribute Details

#confirmObject

Returns the value of attribute confirm.



7
8
9
# File 'lib/dima/html/action.rb', line 7

def confirm
  @confirm
end

#iconObject

Returns the value of attribute icon.



5
6
7
# File 'lib/dima/html/action.rb', line 5

def icon
  @icon
end

#labelObject

Returns the value of attribute label.



5
6
7
# File 'lib/dima/html/action.rb', line 5

def label
  @label
end

#methodObject

Returns the value of attribute method.



8
9
10
# File 'lib/dima/html/action.rb', line 8

def method
  @method
end

#tooltipObject

Returns the value of attribute tooltip.



6
7
8
# File 'lib/dima/html/action.rb', line 6

def tooltip
  @tooltip
end

#urlObject

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