Class: Date::Format::Bag

Inherits:
Object
  • Object
show all
Defined in:
lib/date/format.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initializeBag

Returns a new instance of Bag.



142
143
144
# File 'lib/date/format.rb', line 142

def initialize
  @elem = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(t, *args, &block) ⇒ Object



146
147
148
149
150
151
152
153
154
155
# File 'lib/date/format.rb', line 146

def method_missing(t, *args, &block)
  t = t.to_s
  set = t.chomp!('=')
  t = t.intern
  if set
    @elem[t] = args[0]
  else
    @elem[t]
  end
end

Instance Method Details

#to_hashObject



157
158
159
# File 'lib/date/format.rb', line 157

def to_hash
  @elem.reject{|k, v| /\A_/ =~ k.to_s || v.nil?}
end