Sha256: ee29a8ad87edfa46d4e257c7b77d67e3d37c07db0c7bd03dc84cae8ef0a7b24e
Contents?: true
Size: 1.89 KB
Versions: 121
Compression:
Stored size: 1.89 KB
Contents
require 'rubygems' require 'bundler/setup' require 'ruby-event' module RubyApp module Elements module Mobile module Calendars require 'ruby_app/element' class Month < RubyApp::Element class ChangedEvent < RubyApp::Element::Event attr_reader :value def initialize(data) super(data) @value = data['value'].strip @value = @value.empty? ? nil : Date.parse(@value) end def to_hash super.merge(:value => @value) end end template_path(:all, File.dirname(__FILE__)) attr_accessor :value attr_accessor :display event :changed def initialize(today = Date.today, value = Date.today) super() @today = today @value = value @display = @value end def move_previous!(event) @display = @display << 1 event.update_element(self) end def move_next!(event) @display = @display >> 1 event.update_element(self) end protected def first_date first_of_month = @display - (@display.day - 1) return first_of_month - first_of_month.wday end def last_date next_month = @display >> 1 last_of_month = next_month - next_month.day return last_of_month + (6 - last_of_month.wday) end def on_event(event) on_changed(event) if event.is_a?(RubyApp::Elements::Mobile::Calendars::Month::ChangedEvent) super(event) end def on_changed(event) @value = event.value event.update_element(self) changed(event) end end end end end end
Version data entries
121 entries across 121 versions & 1 rubygems