Sha256: 3e4fda77697b5aba6b2f0ab351b1391647893d04c2e1755d4a1ccb07c0ecaeb2
Contents?: true
Size: 622 Bytes
Versions: 4
Compression:
Stored size: 622 Bytes
Contents
module Piglet module Field class Literal include Field def initialize(obj, options=nil) options ||= {} @obj = obj @type = options[:type] || literal_type(obj) end def to_s case @obj when Numeric @obj.to_s else "'#{escape(@obj.to_s)}'" end end private def literal_type(obj) case obj when String :chararray when Integer :int when Numeric :double else :bytearray end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
piglet-0.2.4 | lib/piglet/field/literal.rb |
piglet-0.2.3 | lib/piglet/field/literal.rb |
piglet-0.2.2 | lib/piglet/field/literal.rb |
piglet-0.2.0 | lib/piglet/field/literal.rb |