Sha256: 15f3744b09931a34ca5bb734e6afcc4368e905073982a689cf818781ec90f359

Contents?: true

Size: 1.18 KB

Versions: 6

Compression:

Stored size: 1.18 KB

Contents

module Nydp
  class StringAtom
    attr_accessor :string

    def initialize string ; @string = string ; end

    def nydp_type  ; :string                                     ; end
    def to_s       ; string                                      ; end
    def to_ruby    ; string                                      ; end
    def to_sym     ; string.to_sym                               ; end
    def to_date    ; ::Date.parse(@string)                       ; end
    def eql? other ; self == other                               ; end
    def inspect    ; string.inspect                              ; end
    def hash       ; string.hash                                 ; end
    def length     ; string.length                               ; end
    def >    other ; self.string > other.string                  ; end
    def <    other ; self.string < other.string                  ; end
    def *    other ; StringAtom.new(string * other)              ; end
    def <=>  other ; self < other ? -1 : (self == other ? 0 : 1) ; end
    def +    other ; StringAtom.new "#{@string}#{other}"         ; end

    def == other
      other.is_a?(Nydp::StringAtom) && (other.to_s == self.to_s)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
nydp-0.6.0 lib/nydp/string_atom.rb
nydp-0.5.1 lib/nydp/string_atom.rb
nydp-0.5.0 lib/nydp/string_atom.rb
nydp-0.4.6 lib/nydp/string_atom.rb
nydp-0.4.5 lib/nydp/string_atom.rb
nydp-0.4.3 lib/nydp/string_atom.rb