Class: BottleRocket::TagBuilders::UnitContainerBuilder
- Inherits:
-
Object
- Object
- BottleRocket::TagBuilders::UnitContainerBuilder
- Includes:
- ContentTags
- Defined in:
- lib/bottle_rocket/tag_builders/unit_container_builder.rb
Instance Attribute Summary collapse
-
#time_unit ⇒ Object
readonly
Returns the value of attribute time_unit.
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
-
#unit_separator ⇒ Object
readonly
Returns the value of attribute unit_separator.
Instance Method Summary collapse
-
#initialize(unit, unit_value, separator_options) ⇒ UnitContainerBuilder
constructor
A new instance of UnitContainerBuilder.
- #singularize? ⇒ Boolean
- #to_html ⇒ Object
Constructor Details
#initialize(unit, unit_value, separator_options) ⇒ UnitContainerBuilder
Returns a new instance of UnitContainerBuilder.
9 10 11 12 13 |
# File 'lib/bottle_rocket/tag_builders/unit_container_builder.rb', line 9 def initialize(unit, unit_value, ) @unit = unit @time_unit = TimeUnitBuilder.new unit, unit_value @unit_separator = UnitSeparatorBuilder.new unit, .merge(singularize: singularize?) end |
Instance Attribute Details
#time_unit ⇒ Object (readonly)
Returns the value of attribute time_unit.
7 8 9 |
# File 'lib/bottle_rocket/tag_builders/unit_container_builder.rb', line 7 def time_unit @time_unit end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
7 8 9 |
# File 'lib/bottle_rocket/tag_builders/unit_container_builder.rb', line 7 def unit @unit end |
#unit_separator ⇒ Object (readonly)
Returns the value of attribute unit_separator.
7 8 9 |
# File 'lib/bottle_rocket/tag_builders/unit_container_builder.rb', line 7 def unit_separator @unit_separator end |
Instance Method Details
#singularize? ⇒ Boolean
15 16 17 |
# File 'lib/bottle_rocket/tag_builders/unit_container_builder.rb', line 15 def singularize? time_unit.one? end |
#to_html ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/bottle_rocket/tag_builders/unit_container_builder.rb', line 19 def to_html ContentTag.new(:span, class: unit.to_s).to_s do if unit_separator.after? [time_unit.to_html, unit_separator.to_html].join else [unit_separator.to_html, time_unit.to_html].join end end end |