Class: ButtonModel
- Inherits:
-
Object
- Object
- ButtonModel
- Defined in:
- lib/glimmer-dsl-web/samples/hello/hello_style.rb
Constant Summary collapse
- BUTTON_STYLE_ATTRIBUTES =
[:width, :height, :font_size, :background_color]
- WIDTH_MIN =
160- WIDTH_MAX =
960- HEIGHT_MIN =
100- HEIGHT_MAX =
600- FONT_SIZE_MIN =
40- FONT_SIZE_MAX =
200
Instance Method Summary collapse
- #border_color ⇒ Object
- #font_size=(value) ⇒ Object
- #height=(value) ⇒ Object
-
#initialize ⇒ ButtonModel
constructor
A new instance of ButtonModel.
- #push ⇒ Object
- #text ⇒ Object
- #width=(value) ⇒ Object
Constructor Details
#initialize ⇒ ButtonModel
Returns a new instance of ButtonModel.
35 36 37 38 39 40 41 |
# File 'lib/glimmer-dsl-web/samples/hello/hello_style.rb', line 35 def initialize @text = 'Push' @width = WIDTH_MIN @height = HEIGHT_MIN @font_size = FONT_SIZE_MIN @background_color = '#add8e6' end |
Instance Method Details
#border_color ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/glimmer-dsl-web/samples/hello/hello_style.rb', line 67 def border_color red = background_color[1..2].hex green = background_color[3..4].hex blue = background_color[5..6].hex new_red = red - 10 new_green = green - 10 new_blue = blue - 10 "##{new_red.to_s(16)}#{new_green.to_s(16)}#{new_blue.to_s(16)}" end |
#font_size=(value) ⇒ Object
61 62 63 64 65 |
# File 'lib/glimmer-dsl-web/samples/hello/hello_style.rb', line 61 def font_size=(value) @font_size = value self.width = @font_size*4 if @height < @font_size*4 self.height = @font_size*2.5 if @height < @font_size*2.5 end |
#height=(value) ⇒ Object
56 57 58 59 |
# File 'lib/glimmer-dsl-web/samples/hello/hello_style.rb', line 56 def height=(value) @height = value self.font_size = @height/2.5 if @font_size > @height/2.5 end |
#push ⇒ Object
43 44 45 |
# File 'lib/glimmer-dsl-web/samples/hello/hello_style.rb', line 43 def push self.pushed = !pushed end |
#text ⇒ Object
47 48 49 |
# File 'lib/glimmer-dsl-web/samples/hello/hello_style.rb', line 47 def text pushed ? 'Pull' : 'Push' end |
#width=(value) ⇒ Object
51 52 53 54 |
# File 'lib/glimmer-dsl-web/samples/hello/hello_style.rb', line 51 def width=(value) @width = value self.font_size = @width/4 if @font_size > @width/4 end |