master
 1class Button
 2  def initialize(name)
 3    @button = UIButton.buttonWithType(UIButtonTypeRoundedRect)
 4    @button.setTitle(name, forState:UIControlStateNormal)
 5    @button.setTitle("Loading", forState:UIControlStateDisabled)
 6    @button.sizeToFit
 7  end
 8  def bind_to(command)
 9    @button.when(UIControlEventTouchUpInside) do
10      command.run(@button)
11    end
12  end
13  def disable
14    @button.enabled=false
15  end
16  def add_to(view)
17    view.addSubview(@button)
18  end
19  def control
20    @button
21  end
22end