Class: Date

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.convert_to(type) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/sinatra/params/date.rb', line 4

def self.convert_to(type)
    table = {
        String => :to_s,
        Integer => :to_i,
        Float => :to_f,
        Array => :to_a,
        Date => :to_date,
        DateTime => :to_datetime,
        Time => :to_time
    }

    table[type]
end

Instance Method Details

#to_fObject



22
23
24
# File 'lib/sinatra/params/date.rb', line 22

def to_f
    self.to_time.to_f
end

#to_iObject



18
19
20
# File 'lib/sinatra/params/date.rb', line 18

def to_i
    self.to_time.to_i
end