Class: Inkcite::Renderer::Button::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/inkcite/renderer/button.rb

Overview

Convenience class which makes it easy to retrieve the attributes for a button.

Instance Method Summary collapse

Constructor Details

#initialize(ctx, opt = {}) ⇒ Config

Returns a new instance of Config.



9
10
11
12
# File 'lib/inkcite/renderer/button.rb', line 9

def initialize ctx, opt={}
  @opt = opt
  @ctx = ctx
end

Instance Method Details

#bevelObject



26
27
28
# File 'lib/inkcite/renderer/button.rb', line 26

def bevel
  (@opt[:bevel] || @ctx[BUTTON_BEVEL]).to_i
end

#bevel_colorObject



30
31
32
# File 'lib/inkcite/renderer/button.rb', line 30

def bevel_color
  @opt[BEVEL_COLOR] || @ctx[BUTTON_BEVEL_COLOR]
end

#bgcolorObject



14
15
16
# File 'lib/inkcite/renderer/button.rb', line 14

def bgcolor
  hex(@opt[:bgcolor] || @ctx[BUTTON_BGCOLOR] || @ctx[BUTTON_BACKGROUND_COLOR])
end

#borderObject



18
19
20
# File 'lib/inkcite/renderer/button.rb', line 18

def border
  @opt[:border] || @ctx[BUTTON_BORDER]
end

#border_bottomObject



22
23
24
# File 'lib/inkcite/renderer/button.rb', line 22

def border_bottom
  "#{Renderer.px(bevel)} solid #{bevel_color}" if bevel > 0
end

#border_radiusObject



34
35
36
# File 'lib/inkcite/renderer/button.rb', line 34

def border_radius
  (@opt[Base::BORDER_RADIUS] || @ctx[BUTTON_BORDER_RADIUS]).to_i
end

#colorObject



38
39
40
# File 'lib/inkcite/renderer/button.rb', line 38

def color
  hex(@opt[:color] || @ctx[BUTTON_COLOR])
end

#floatObject



42
43
44
# File 'lib/inkcite/renderer/button.rb', line 42

def float
  @opt[:align] || @opt[:float] || @ctx[BUTTON_FLOAT]
end

#fontObject



46
47
48
# File 'lib/inkcite/renderer/button.rb', line 46

def font
  @opt[:font] || @ctx[BUTTON_FONT]
end

#font_sizeObject



50
51
52
# File 'lib/inkcite/renderer/button.rb', line 50

def font_size
  (@opt[Base::FONT_SIZE] || @ctx[BUTTON_FONT_SIZE]).to_i
end

#font_weightObject



54
55
56
# File 'lib/inkcite/renderer/button.rb', line 54

def font_weight
  @opt[Base::FONT_WEIGHT] || @ctx[BUTTON_FONT_WEIGHT]
end

#heightObject



58
59
60
# File 'lib/inkcite/renderer/button.rb', line 58

def height
  (@opt[:height] || @ctx[BUTTON_HEIGHT]).to_i
end

#letter_spacingObject



62
63
64
# File 'lib/inkcite/renderer/button.rb', line 62

def letter_spacing
  @opt[Base::LETTER_SPACING] || @ctx[BUTTON_LETTER_SPACING]
end

#line_heightObject



66
67
68
# File 'lib/inkcite/renderer/button.rb', line 66

def line_height
  @opt[Base::LINE_HEIGHT] || @ctx[BUTTON_LINE_HEIGHT]
end

#margin_topObject



70
71
72
# File 'lib/inkcite/renderer/button.rb', line 70

def margin_top
  (@opt[Base::MARGIN_TOP] || @ctx[BUTTON_MARGIN_TOP]).to_i
end

#paddingObject



74
75
76
# File 'lib/inkcite/renderer/button.rb', line 74

def padding
  (@opt[:padding] || @ctx[BUTTON_PADDING]).to_i
end

#text_shadowObject



78
79
80
# File 'lib/inkcite/renderer/button.rb', line 78

def text_shadow
  hex(@opt[Base::TEXT_SHADOW] || @ctx[BUTTON_TEXT_SHADOW])
end

#widthObject



82
83
84
# File 'lib/inkcite/renderer/button.rb', line 82

def width
  (@opt[:width] || @ctx[BUTTON_WIDTH]).to_i
end