Sha256: 6cbceca1c8aa107b8e9edd7bc591ed790e57028d35b97f8a2d3e0072188f8ad9
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
# encoding: utf-8 # Represents a Field in a Vocabulary # This is an abstract class. The concrete class must implement: # # fromString() -- Returns contents from a string without input processing # contents() -- Returns the contents of the field unaltered # raw() -- Returns a string of the contents unaltered # copy() -- Copies the contents from a field if it is assigned # eql?() -- Returns true if the contents are eql? to the passed contents module JLDrill class Field QUOTE_RE = /["]/ RETURN_RE = /[\n]/ SLASH_RE = /[\/]/ ESCAPED_COMMA_RE = Regexp.new("\\,", nil) ESCAPED_SLASH_RE = Regexp.new("\\/", nil) def initialize(name) @name = name end def processInput(text) if text.nil? || text.empty? return nil end text = text.gsub(RETURN_RE, "\\n") text end def processOutput(text) if text.nil? return nil end text = text.gsub(ESCAPED_COMMA_RE, ",") text = text.gsub(ESCAPED_SLASH_RE, "/") eval("\"#{text.gsub(QUOTE_RE, "\\\"")}\"") end def assign(string) string = processInput(string) fromString(string) end def assigned? !contents().nil? && !contents.empty? end def output if assigned? processOutput(raw()) else nil end end def to_s if assigned? "/#{@name}: " + raw() else "" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jldrill-0.6.0.1 | lib/jldrill/model/items/Field.rb |