Class: Inkcite::Renderer::Button::Config
- Inherits:
-
Object
- Object
- Inkcite::Renderer::Button::Config
- 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
- #bevel ⇒ Object
- #bevel_color ⇒ Object
- #bgcolor ⇒ Object
- #border ⇒ Object
- #border_bottom ⇒ Object
- #border_radius ⇒ Object
- #color ⇒ Object
- #float ⇒ Object
- #font ⇒ Object
- #font_size ⇒ Object
- #font_weight ⇒ Object
- #height ⇒ Object
-
#initialize(ctx, opt = {}) ⇒ Config
constructor
A new instance of Config.
- #letter_spacing ⇒ Object
- #line_height ⇒ Object
- #margin_top ⇒ Object
- #padding ⇒ Object
- #text_shadow ⇒ Object
- #width ⇒ Object
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
#bevel ⇒ Object
26 27 28 |
# File 'lib/inkcite/renderer/button.rb', line 26 def bevel (@opt[:bevel] || @ctx[BUTTON_BEVEL]).to_i end |
#bevel_color ⇒ Object
30 31 32 |
# File 'lib/inkcite/renderer/button.rb', line 30 def bevel_color @opt[BEVEL_COLOR] || @ctx[BUTTON_BEVEL_COLOR] end |
#bgcolor ⇒ Object
14 15 16 |
# File 'lib/inkcite/renderer/button.rb', line 14 def bgcolor hex(@opt[:bgcolor] || @ctx[BUTTON_BGCOLOR] || @ctx[BUTTON_BACKGROUND_COLOR]) end |
#border ⇒ Object
18 19 20 |
# File 'lib/inkcite/renderer/button.rb', line 18 def border @opt[:border] || @ctx[BUTTON_BORDER] end |
#border_bottom ⇒ Object
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_radius ⇒ Object
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 |
#color ⇒ Object
38 39 40 |
# File 'lib/inkcite/renderer/button.rb', line 38 def color hex(@opt[:color] || @ctx[BUTTON_COLOR]) end |
#float ⇒ Object
42 43 44 |
# File 'lib/inkcite/renderer/button.rb', line 42 def float @opt[:align] || @opt[:float] || @ctx[BUTTON_FLOAT] end |
#font ⇒ Object
46 47 48 |
# File 'lib/inkcite/renderer/button.rb', line 46 def font @opt[:font] || @ctx[BUTTON_FONT] end |
#font_size ⇒ Object
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_weight ⇒ Object
54 55 56 |
# File 'lib/inkcite/renderer/button.rb', line 54 def font_weight @opt[Base::FONT_WEIGHT] || @ctx[BUTTON_FONT_WEIGHT] end |
#height ⇒ Object
58 59 60 |
# File 'lib/inkcite/renderer/button.rb', line 58 def height (@opt[:height] || @ctx[BUTTON_HEIGHT]).to_i end |
#letter_spacing ⇒ Object
62 63 64 |
# File 'lib/inkcite/renderer/button.rb', line 62 def letter_spacing @opt[Base::LETTER_SPACING] || @ctx[BUTTON_LETTER_SPACING] end |
#line_height ⇒ Object
66 67 68 |
# File 'lib/inkcite/renderer/button.rb', line 66 def line_height @opt[Base::LINE_HEIGHT] || @ctx[BUTTON_LINE_HEIGHT] end |
#margin_top ⇒ Object
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 |
#padding ⇒ Object
74 75 76 |
# File 'lib/inkcite/renderer/button.rb', line 74 def padding (@opt[:padding] || @ctx[BUTTON_PADDING]).to_i end |
#text_shadow ⇒ Object
78 79 80 |
# File 'lib/inkcite/renderer/button.rb', line 78 def text_shadow hex(@opt[Base::TEXT_SHADOW] || @ctx[BUTTON_TEXT_SHADOW]) end |
#width ⇒ Object
82 83 84 |
# File 'lib/inkcite/renderer/button.rb', line 82 def width (@opt[:width] || @ctx[BUTTON_WIDTH]).to_i end |