Class: BottleRocket::TimeUnitBuilder

Inherits:
Object
  • Object
show all
Includes:
ContentTags
Defined in:
lib/bottle_rocket/tag_builders/time_unit_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(unit, value) ⇒ TimeUnitBuilder

Returns a new instance of TimeUnitBuilder.



7
8
9
10
# File 'lib/bottle_rocket/tag_builders/time_unit_builder.rb', line 7

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

Instance Attribute Details

#unitObject (readonly)

Returns the value of attribute unit.



5
6
7
# File 'lib/bottle_rocket/tag_builders/time_unit_builder.rb', line 5

def unit
  @unit
end

#valueObject (readonly)

Returns the value of attribute value.



5
6
7
# File 'lib/bottle_rocket/tag_builders/time_unit_builder.rb', line 5

def value
  @value
end

Instance Method Details

#one?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/bottle_rocket/tag_builders/time_unit_builder.rb', line 12

def one?
  [-1, 1].include? value
end

#to_htmlObject



16
17
18
19
20
# File 'lib/bottle_rocket/tag_builders/time_unit_builder.rb', line 16

def to_html
  ContentTag.new(:span, class: "#{unit}-#{value}").to_s do
    value.to_s
  end
end