Class: Glimmer::Calculator

Inherits:
Object
  • Object
show all
Includes:
UI::CustomShell
Defined in:
lib/views/glimmer/calculator.rb,
lib/models/glimmer/calculator/command.rb,
lib/models/glimmer/calculator/presenter.rb,
lib/models/glimmer/calculator/command/point.rb,
lib/models/glimmer/calculator/command/equals.rb,
lib/models/glimmer/calculator/command/number.rb,
lib/models/glimmer/calculator/command/all_clear.rb,
lib/models/glimmer/calculator/command/operation.rb,
lib/models/glimmer/calculator/command/operation/add.rb,
lib/models/glimmer/calculator/command/operation/divide.rb,
lib/models/glimmer/calculator/command/operation/multiply.rb,
lib/models/glimmer/calculator/command/operation/subtract.rb

Defined Under Namespace

Classes: Command, Presenter

Constant Summary collapse

APP_ROOT =
File.expand_path('../../../..', __FILE__)
VERSION =
File.read(File.expand_path(File.join('..', '..', '..', '..', 'VERSION'), __FILE__))
LICENSE =
File.read(File.expand_path(File.join('..', '..', '..', '..', 'LICENSE.txt'), __FILE__))

Instance Method Summary collapse

Instance Method Details

#command_button(command, options = {}) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/views/glimmer/calculator.rb', line 98

def command_button(command, options = {})
  command = command.to_s
  options[:font] ||= @button_font
  options[:horizontal_span] ||= 1
  options[:vertical_span] ||= 1
  
  button { |proxy|
    text command
    font options[:font]
    
    layout_data(:fill, :fill, true, true) {
      horizontal_span options[:horizontal_span]
      vertical_span options[:vertical_span]
    }
    
    on_widget_selected {
      @presenter.press(command)
    }
  }    
end

#display_about_dialogObject



119
120
121
122
123
124
# File 'lib/views/glimmer/calculator.rb', line 119

def display_about_dialog
  message_box(body_root) {
    text 'About'
    message "Glimmer - Calculator #{VERSION}\n#{LICENSE}"
  }.open
end

#number_button(number, options = {}) ⇒ Object



90
91
92
# File 'lib/views/glimmer/calculator.rb', line 90

def number_button(number, options = {})
  command_button(number, options)
end

#operation_button(operation, options = {}) ⇒ Object



94
95
96
# File 'lib/views/glimmer/calculator.rb', line 94

def operation_button(operation, options = {})
  command_button(operation, options.merge(font: @button_font_operation))
end