module ScopeMethods::IntanceMethods
Constants
- MIN_ACCEPTED_YEAR
Public Instance Methods
<=>(other)
click to toggle source
# File lib/scope_methods.rb, line 91 def <=>(other) to_date <=> other.to_date end
month()
click to toggle source
# File lib/scope_methods.rb, line 65 def month Scope.month @value end
month_to_s()
click to toggle source
# File lib/scope_methods.rb, line 69 def month_to_s month < 10 ? "0#{month.to_i}" : "#{month.to_i}" end
next()
click to toggle source
# File lib/scope_methods.rb, line 78 def next date = Scope.scope_to_date(@value).next_month Scope.date_to_scope date end
prior()
click to toggle source
# File lib/scope_methods.rb, line 73 def prior date = Scope.scope_to_date(@value).prev_month Scope.date_to_scope date end
span(end_scope)
click to toggle source
# File lib/scope_methods.rb, line 95 def span(end_scope) (end_scope = Scope.new(end_scope)) unless end_scope.is_a?(Scope) raise "Current Scope (#{to_s}) bigger or equal to end scope (#{end_scope.to_s})" if (self >= end_scope) scope_span = [] current_scope = Scope.new(to_s) while current_scope <= end_scope scope_span << current_scope current_scope = current_scope.next end scope_span end
to_date()
click to toggle source
# File lib/scope_methods.rb, line 87 def to_date Scope.scope_to_date @value end
to_i()
click to toggle source
# File lib/scope_methods.rb, line 83 def to_i @value.to_i end
to_s()
click to toggle source
# File lib/scope_methods.rb, line 57 def to_s @value end
valid?()
click to toggle source
# File lib/scope_methods.rb, line 53 def valid? Scope.valid? @value end
year()
click to toggle source
# File lib/scope_methods.rb, line 61 def year Scope.year @value end
Private Instance Methods
get_short_value()
click to toggle source
# File lib/scope_methods.rb, line 112 def get_short_value raise "year (#{year}) shorten than #{MIN_ACCEPTED_YEAR}" if year < MIN_ACCEPTED_YEAR "#{year - 2000}#{month_to_s}" end