Class: Array

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

def self.convert_to(type)
    table = {
        Array => :to_a,
        String => :to_s,
        Date => :to_date,
        DateTime => :to_datetime
    }

    table[type]
end

Instance Method Details

#to_dateObject



15
16
17
# File 'lib/sinatra/params/array.rb', line 15

def to_date
    Date.parse(self.join('-'))
end

#to_datetimeObject



19
20
21
# File 'lib/sinatra/params/array.rb', line 19

def to_datetime
    DateTime.parse(self.join('-'))
end