Class: Forma::Html::SimpleAttr

Inherits:
Attr
  • Object
show all
Defined in:
lib/forma/html.rb

Overview

Simple attribute.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value) ⇒ SimpleAttr

Returns a new instance of SimpleAttr.



54
55
56
57
# File 'lib/forma/html.rb', line 54

def initialize(name, value)
  @name = name
  @value = value
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



53
54
55
# File 'lib/forma/html.rb', line 53

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value.



53
54
55
# File 'lib/forma/html.rb', line 53

def value
  @value
end

Instance Method Details

#to_sObject



59
60
61
62
63
64
65
# File 'lib/forma/html.rb', line 59

def to_s
  if @name == 'value'
    %Q{#{@name}="#{ERB::Util.html_escape(@value)}"}
  elsif @name.present? and @value.present?
    %Q{#{@name}="#{ERB::Util.html_escape(@value)}"}
  end
end