Class: Integer

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/params/integer.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
# File 'lib/sinatra/params/integer.rb', line 4

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

    table[type]
end

Instance Method Details

#to_dateObject



21
22
23
# File 'lib/sinatra/params/integer.rb', line 21

def to_date
    Time.at(self).to_date
end

#to_datetimeObject



25
26
27
# File 'lib/sinatra/params/integer.rb', line 25

def to_datetime
    Time.at(self).to_datetime
end

#to_timeObject



17
18
19
# File 'lib/sinatra/params/integer.rb', line 17

def to_time
    Time.at(self)
end