Class: ButtonModel

Inherits:
Object
  • Object
show all
Defined in:
lib/glimmer-dsl-web/samples/hello/hello_style.rb

Constant Summary collapse

WIDTH_MIN =
160
WIDTH_MAX =
960
HEIGHT_MIN =
100
HEIGHT_MAX =
600
FONT_SIZE_MIN =
40
FONT_SIZE_MAX =
200

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeButtonModel

Returns a new instance of ButtonModel.



34
35
36
37
38
39
40
# File 'lib/glimmer-dsl-web/samples/hello/hello_style.rb', line 34

def initialize
  @text = 'Push'
  @width = WIDTH_MIN
  @height = HEIGHT_MIN
  @font_size = FONT_SIZE_MIN
  @background_color = '#add8e6'
end

Instance Attribute Details

#background_colorObject

Returns the value of attribute background_color.



32
33
34
# File 'lib/glimmer-dsl-web/samples/hello/hello_style.rb', line 32

def background_color
  @background_color
end

#font_sizeObject

Returns the value of attribute font_size.



32
33
34
# File 'lib/glimmer-dsl-web/samples/hello/hello_style.rb', line 32

def font_size
  @font_size
end

#heightObject

Returns the value of attribute height.



32
33
34
# File 'lib/glimmer-dsl-web/samples/hello/hello_style.rb', line 32

def height
  @height
end

#pushedObject

Returns the value of attribute pushed.



32
33
34
# File 'lib/glimmer-dsl-web/samples/hello/hello_style.rb', line 32

def pushed
  @pushed
end

#textObject

Returns the value of attribute text.



32
33
34
# File 'lib/glimmer-dsl-web/samples/hello/hello_style.rb', line 32

def text
  @text
end

#widthObject

Returns the value of attribute width.



32
33
34
# File 'lib/glimmer-dsl-web/samples/hello/hello_style.rb', line 32

def width
  @width
end

Instance Method Details

#border_colorObject



66
67
68
69
70
71
72
73
74
# File 'lib/glimmer-dsl-web/samples/hello/hello_style.rb', line 66

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

#pushObject



42
43
44
# File 'lib/glimmer-dsl-web/samples/hello/hello_style.rb', line 42

def push
  self.pushed = !pushed
end