Class: Playbook::PbCurrency::Currency

Inherits:
Object
  • Object
show all
Includes:
ActionView::Context, Playbook::Props
Defined in:
app/pb_kits/playbook/pb_currency/currency.rb

Instance Method Summary collapse

Methods included from Playbook::Props

#generate_classname, #initialize, #prop

Instance Method Details

#amount_elementObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/pb_kits/playbook/pb_currency/currency.rb', line 60

def amount_element
  whole_part = amount.split(".")
  pb_title = Playbook::PbTitle::Title.new(
    size: size_value,
    text: whole_part.first.to_s,
    classname: "pb_currency_value",
    dark: dark
  )

  ApplicationController.renderer.render(
    partial: pb_title,
    as: :object
  )
end

#classnameObject



34
35
36
# File 'app/pb_kits/playbook/pb_currency/currency.rb', line 34

def classname
  generate_classname("pb_currency_kit", align, size, dark_class)
end

#currency_symbol_elementObject



38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/pb_kits/playbook/pb_currency/currency.rb', line 38

def currency_symbol_element
  pb_dollar_sign = Playbook::PbBody::Body.new(
    classname: "dollar_sign",
    color: "light",
    dark: dark
  ) { symbol }

  ApplicationController.renderer.render(
    partial: pb_dollar_sign,
    as: :object
  )
end

#label_elementObject



51
52
53
54
55
56
57
58
# File 'app/pb_kits/playbook/pb_currency/currency.rb', line 51

def label_element
  pb_label = Playbook::PbCaption::Caption.new(text: label)

  ApplicationController.renderer.render(
    partial: pb_label,
    as: :object
  )
end

#units_elementObject



75
76
77
78
79
80
81
82
# File 'app/pb_kits/playbook/pb_currency/currency.rb', line 75

def units_element
  _, decimal_part = amount.split(".")
  if unit.nil?
    decimal_part.nil? ? ".00" : ".#{decimal_part}"
  else
    unit
  end
end