Sha256: d43a6922abfcc2706e9a643cfa6b44b81f6068bda88fc723f728a28d877d2251

Contents?: true

Size: 563 Bytes

Versions: 4

Compression:

Stored size: 563 Bytes

Contents

require 'date'

module CandyCheck
  module Utils
    # @private
    module AttributeReader
      protected

      def read(field)
        attributes[field]
      end

      def has?(field)
        attributes.key?(field)
      end

      def read_integer(field)
        (val = read(field)) && val.to_i
      end

      def read_datetime_from_string(field)
        (val = read(field)) && DateTime.parse(val)
      end

      def read_datetime_from_millis(field)
        (val = read_integer(field)) && Time.at(val / 1000).utc.to_datetime
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
candy_check-0.0.5 lib/candy_check/utils/attribute_reader.rb
candy_check-0.0.3 lib/candy_check/utils/attribute_reader.rb
candy_check-0.0.2 lib/candy_check/utils/attribute_reader.rb
candy_check-0.0.1 lib/candy_check/utils/attribute_reader.rb