class Object

Constants

Address
COLOR_BLUE
GIRB_RUNNER_EXIT_FILE
IMAGE_ROWS
MAIN_WINDOW
POINT_RADIUS
X_OFF_LEFT
X_OFF_RIGHT
Y_OFF_BOTTOM
Y_OFF_TOP

Public Class Methods

exit(*args) click to toggle source
# File bin/girb_runner.rb, line 39
def self.exit(*args)
  @exit_girb_block.call
  @exit_method.call(*args)
end
quit(*args) click to toggle source
# File bin/girb_runner.rb, line 44
def self.quit(*args)
  @exit_girb_block.call
  @exit_method.call(*args)
end

Public Instance Methods

address_form(address_model) click to toggle source
# File examples/method_based_custom_controls.rb, line 16
def address_form(address_model)
  form {
    form_field(address_model, :street)
    form_field(address_model, :p_o_box)
    form_field(address_model, :city)
    form_field(address_model, :state)
    form_field(address_model, :zip_code)
  }
end
address_view(address_model) click to toggle source
# File examples/method_based_custom_controls.rb, line 35
def address_view(address_model)
  vertical_box {
    address_model.each_pair do |attribute, value|
      label_pair(address_model, attribute, value)
    end
  }
end
form_field(model, attribute) click to toggle source
# File examples/method_based_custom_controls.rb, line 8
def form_field(model, attribute)
  attribute = attribute.to_s
  entry { |e|
    label attribute.underscore.split('_').map(&:capitalize).join(' ')
    text <=> [model, attribute]
  }
end
graph_path(width, height, should_extend, &block) click to toggle source

method-based custom control representing a graph path

# File examples/histogram2.rb, line 34
def graph_path(width, height, should_extend, &block)
  locations = point_locations(width, height).flatten
  path {
    if should_extend
      polygon(locations + [width, height, 0, height])
    else
      polyline(locations)
    end
    
    # apply a transform to the coordinate space for this path so (0, 0) is the top-left corner of the graph
    transform {
      translate X_OFF_LEFT, Y_OFF_TOP
    }
    
    block.call
  }
end
graph_size(area_width, area_height) click to toggle source
# File examples/histogram2.rb, line 17
def graph_size(area_width, area_height)
  graph_width = area_width - X_OFF_LEFT - X_OFF_RIGHT
  graph_height = area_height - Y_OFF_TOP - Y_OFF_BOTTOM
  [graph_width, graph_height]
end
label_pair(model, attribute, value) click to toggle source
# File examples/method_based_custom_controls.rb, line 26
def label_pair(model, attribute, value)
  horizontal_box {
    label(attribute.to_s.underscore.split('_').map(&:capitalize).join(' '))
    label(value.to_s) {
      text <= [model, attribute]
    }
  }
end
point_locations(width, height) click to toggle source
# File examples/histogram2.rb, line 23
def point_locations(width, height)
  xincr = width / 9.0 # 10 - 1 to make the last point be at the end
  yincr = height / 100.0

  @datapoints.each_with_index.map do |value, i|
    val = 100 - value
    [xincr * i, yincr * val]
  end
end