Sha256: e04fbe005f1decc0e395da8acbc3891b0944720783b55583888668875f580e4b

Contents?: true

Size: 650 Bytes

Versions: 7

Compression:

Stored size: 650 Bytes

Contents

# frozen_string_literal: true

class Code
  class Object
    class Date < Object
      attr_reader :raw

      def initialize(date)
        @raw = date
      end

      def self.name
        "Date"
      end

      def self.call(**args)
        operator = args.fetch(:operator, nil)

        case operator.to_s
        when "tomorrow"
          sig(args)
          code_tomorrow
        else
          super
        end
      end

      def self.code_tomorrow
        ::Time.zone ||= Time::DEFAULT_ZONE
        new(::Time.zone.tomorrow)
      end

      def inspect
        to_s
      end

      def to_s
        raw.to_s
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
code-ruby-0.9.0 lib/code/object/date.rb
code-ruby-0.8.5 lib/code/object/date.rb
code-ruby-0.8.4 lib/code/object/date.rb
code-ruby-0.8.3 lib/code/object/date.rb
code-ruby-0.8.2 lib/code/object/date.rb
code-ruby-0.8.1 lib/code/object/date.rb
code-ruby-0.8.0 lib/code/object/date.rb