Sha256: caa014bcf786bc32c3d7f9df6ef597f2c6e36bad5e46eeea180a982053c87a41

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

module RubyPager
  class Metadata

    attr_reader :creator
    def initialize(ex_data)
      @data=ex_data
      @creator = @data["Creator"]
      @created = DateTime.parse(@data["Created"])
      @lastchange = DateTime.parse(@data["LastChange"])
    end

    def creator= (ex_creator)
      raise(ArgumentError, "Got passed a non string object") if ex_creator.class != String
      @creator=ex_creator
    end

    def created
      return @created.strftime("%FT%T")
    end

    def created= (ex_created)
      raise(ArgumentError, "Got passed a non DateTime object") if ex_created.class != DateTime
      @created=ex_created
    end

    def lastchange
      return @lastchange.strftime("%FT%T")
    end

    def lastchange= (ex_lastchange)
      raise(ArgumentError, "Got passed a non DateTime object") if ex_lastchange.class != DateTime
      @lastchange=ex_lastchange
    end

    def self.blank_data
      res=Hash.new
      res["Creator"]="Ruby Page"
      res["Created"]=DateTime.now.strftime("%FT%T")
      res["LastChange"]=DateTime.now.strftime("%FT%T")
      return res
    end

    def get_consolidated_data
      consolidate_data()
      return @data
    end

    private

    def consolidate_data()
      @data["Creator"]=@creator
      @data["Created"]=self.created
      @data["LastChange"]=self.lastchange
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby_pager-0.1.3 lib/ruby_pager/metadata.rb
ruby_pager-0.1.2 lib/ruby_pager/metadata.rb
ruby_pager-0.1.1 lib/ruby_pager/metadata.rb