Class: Gtk2AppLib::Dialogs::GetDate

Inherits:
Gtk::Dialog
  • Object
show all
Defined in:
lib/gtk2applib/dialogs/get_date.rb

Overview

creates a get date dialog

Instance Method Summary collapse

Constructor Details

#initialize(date, options) ⇒ GetDate



8
9
10
11
12
13
14
15
16
17
# File 'lib/gtk2applib/dialogs/get_date.rb', line 8

def initialize(date, options)
  @options = options
  super(@options[:TITLE],
    @options[:WINDOW], @options[:FLAGS], *@options[:DIALOG_BUTTONS])
  @date = (date.class == String)?
    date.split(/\D+/).map { |number| number.to_i } : date
  @calendar = Widgets::Calendar.new(self.vbox, *@options[:Calendar])
  @calendar.select_month(@date[1], @date[0])
  @calendar.select_day(@date[2])
end

Instance Method Details

#runObject



24
25
26
27
28
29
30
# File 'lib/gtk2applib/dialogs/get_date.rb', line 24

def run
  date = nil
  self.show_all
  super() { |response| date = self.run_date if response == 1 }
  self.destroy
  date
end

#run_dateObject



19
20
21
22
# File 'lib/gtk2applib/dialogs/get_date.rb', line 19

def run_date
  @calendar.date.map { |number|
    (number>9)? "#{number}": "0#{number}" }.join(@options[:SEP])
end