class Bake::Types::Array

Public Class Methods

new(item_type) click to toggle source
# File lib/bake/types/array.rb, line 30
def initialize(item_type)
        @item_type = item_type
end

Public Instance Methods

composite?() click to toggle source
# File lib/bake/types/array.rb, line 34
def composite?
        true
end
map(values) click to toggle source
# File lib/bake/types/array.rb, line 38
def map(values)
        values.map{|value| @item_type.parse(value)}
end
parse(input) click to toggle source
# File lib/bake/types/array.rb, line 42
def parse(input)
        case input
        when ::String
                return input.split(',').map{|value| @item_type.parse(value)}
        when ::Array
                return input.map{|value| @item_type.parse(value)}
        else
                raise ArgumentError, "Cannot coerce #{input.inspect} into array!"
        end
end
to_s() click to toggle source
# File lib/bake/types/array.rb, line 53
def to_s
        "an Array of #{@item_type}"
end