Class: Roebe::Shell::TimeConverter
- Inherits:
-
Object
- Object
- Roebe::Shell::TimeConverter
show all
- Defined in:
- lib/roebe/shell/standalone_classes/time_converter.rb
Overview
Roebe::Shell::TimeConverter
Constant Summary
collapse
- DEBUG =
#
Roebe::Shell::TimeConverter::DEBUG
#
false
- HASH =
#
Roebe::Shell::TimeConverter::HASH
#
{
'Mon' => 'Monday',
'Tue' => 'Tuesday',
'Wed' => 'Wednesday',
'Thu' => 'Thursday',
'Fri' => 'Friday',
'Sat' => 'Saturday',
'Sun' => 'Sunday'
}
Instance Method Summary
collapse
Constructor Details
#initialize(string = nil) ⇒ TimeConverter
39
40
41
42
43
44
|
# File 'lib/roebe/shell/standalone_classes/time_converter.rb', line 39
def initialize(
string = nil
)
sanitize_string(string)
@year, @month, @day = @string.split('.').reverse
end
|
Instance Method Details
#debug? ⇒ Boolean
61
62
63
|
# File 'lib/roebe/shell/standalone_classes/time_converter.rb', line 61
def debug?
DEBUG
end
|
#return_weekday ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/roebe/shell/standalone_classes/time_converter.rb', line 68
def return_weekday
e @year.to_s+' '+@month.to_s+' '+@day.to_s if debug?
begin
_ = ::Time.mktime(@year, @month, @day).wday
_ = Roebe.weekday?(_)
return HASH[_]
rescue ArgumentError
e 'Error. The time format was not correct. Make sure to input a'
e 'valid notation such as: 10.11.2013'
return nil end
end
|
#sanitize_string(i) ⇒ Object
49
50
51
52
53
54
55
56
|
# File 'lib/roebe/shell/standalone_classes/time_converter.rb', line 49
def sanitize_string(i)
i = i.first if i.is_a? Array case i
when 'today'
i = Time.now.strftime('%d.%m.%Y')
end
@string = i
end
|