Class: Shaf::Formable::Field
- Inherits:
-
Object
- Object
- Shaf::Formable::Field
- Defined in:
- lib/shaf/formable.rb
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #has_value? ⇒ Boolean
-
#initialize(name, params = {}) ⇒ Field
constructor
A new instance of Field.
- #to_html ⇒ Object
Constructor Details
#initialize(name, params = {}) ⇒ Field
Returns a new instance of Field.
6 7 8 9 10 11 12 |
# File 'lib/shaf/formable.rb', line 6 def initialize(name, params = {}) @name = name @type = params[:type] @label = params[:label] @has_value = params.key? :value @value = params[:value] end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
4 5 6 |
# File 'lib/shaf/formable.rb', line 4 def label @label end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/shaf/formable.rb', line 4 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/shaf/formable.rb', line 4 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/shaf/formable.rb', line 4 def value @value end |
Instance Method Details
#has_value? ⇒ Boolean
14 15 16 |
# File 'lib/shaf/formable.rb', line 14 def has_value? @has_value end |
#to_html ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/shaf/formable.rb', line 18 def to_html [ '<div class="form--input-group">', label_element, input_element, '</div>' ].compact.join("\n") end |