class Lebowski::SCUI::Views::DatePickerCalendar
Public Class Methods
new(parent)
click to toggle source
# File lib/lebowski/scui/views/date_picker.rb, line 77 def initialize(parent) @today_button = parent['_calendar_popup.contentView.todayButton'] @none_button = parent['_calendar_popup.contentView.noneButton'] @calendar = parent['_calendar_popup.contentView.calendar'] @parent = parent end
Public Instance Methods
date_selected?(date)
click to toggle source
# File lib/lebowski/scui/views/date_picker.rb, line 84 def date_selected?(date) curr_year = @calendar['selectedDate.year'] curr_month = @calendar['selectedDate.month'] curr_day = @calendar['selectedDate.day'] if date.nil? return false if !(curr_month.nil? && curr_day.nil? && curr_year.nil?) else return false if !((curr_month == date.month) && (curr_day == date.day) && (curr_year == date.year)) end return true end
select_date(date)
click to toggle source
# File lib/lebowski/scui/views/date_picker.rb, line 107 def select_date(date) raise ArgumentError.new "A DateTime object must be provided to the pick_date method." if !(date.class == DateTime || date.class == Time) if @calendar['selectedDate'].nil? year_displayed = @calendar['monthStartOn.year'] month_displayed = @calendar['monthStartOn.month'] else year_displayed = @calendar['selectedDate.year'] month_displayed = @calendar['selectedDate.month'] end year_diff = date.year - year_displayed month_diff = date.month - month_displayed date_diff = year_diff * 12 + month_diff if date_diff > 0 #date in the future date_diff.abs.times { select_next_month } elsif date_diff < 0 #date in the past date_diff.abs.times { select_previous_month } else @parent.display_calendar end date_int = date.day + @calendar['monthStartOn.dayOfWeek'] + 1 @calendar.child_views[date_int].click end
select_next_month()
click to toggle source
# File lib/lebowski/scui/views/date_picker.rb, line 141 def select_next_month @parent.display_calendar next_month = @calendar.child_views[1] next_month.click end
select_none()
click to toggle source
# File lib/lebowski/scui/views/date_picker.rb, line 147 def select_none @parent.display_calendar @none_button.click end
select_previous_month()
click to toggle source
# File lib/lebowski/scui/views/date_picker.rb, line 135 def select_previous_month @parent.display_calendar prev_month = @calendar.child_views[0] prev_month.click end
select_today()
click to toggle source
# File lib/lebowski/scui/views/date_picker.rb, line 152 def select_today @parent.display_calendar @today_button.click end
showing_month?(month)
click to toggle source
# File lib/lebowski/scui/views/date_picker.rb, line 97 def showing_month?(month) month_displayed = @calendar['monthStartOn.month'] - 1 return @calendar['monthStrings'][month_displayed] == month end
showing_year?(year)
click to toggle source
# File lib/lebowski/scui/views/date_picker.rb, line 102 def showing_year?(year) year_displayed = @calendar['monthStartOn.year'] return year_displayed == year end