Class: Rubyvis::Format::Date
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
-
#format(d) ⇒ Object
@pad=Rubyvis::Format.pad.
- #format_lambda ⇒ Object
-
#initialize(pattern) ⇒ Date
constructor
A new instance of Date.
- #parse(s) ⇒ Object
Constructor Details
#initialize(pattern) ⇒ Date
Returns a new instance of Date.
6 7 8 9 |
# File 'lib/rubyvis/format/date.rb', line 6 def initialize(pattern) @pattern=pattern #@pad=Rubyvis::Format.pad end |
Instance Attribute Details
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
5 6 7 |
# File 'lib/rubyvis/format/date.rb', line 5 def pattern @pattern end |
Instance Method Details
#format(d) ⇒ Object
@pad=Rubyvis::Format.pad
10 11 12 |
# File 'lib/rubyvis/format/date.rb', line 10 def format(d) d.strftime(pattern) end |
#format_lambda ⇒ Object
13 14 15 16 17 18 |
# File 'lib/rubyvis/format/date.rb', line 13 def format_lambda pat=pattern lambda {|d| d.strftime(pat) } end |
#parse(s) ⇒ Object
19 20 21 22 |
# File 'lib/rubyvis/format/date.rb', line 19 def parse(s) time=::DateTime.strptime(s, pattern) Time.utc(time.year, time.month, time.day, time.hour, time.min, time.sec, 0) end |