Sha256: d2ce492366055b068ba9429a3da8ab76e5489f68f763da74ff9f2ef7c73ba408

Contents?: true

Size: 610 Bytes

Versions: 4

Compression:

Stored size: 610 Bytes

Contents

# frozen_string_literal: true

class Code
  class Object
    class Duration < Object
      attr_reader :raw

      def initialize(duration)
        @raw = duration
      end

      def self.name
        "Duration"
      end

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

        case operator.to_s
        when "from_now"
          sig(args)
          code_from_now
        else
          super
        end
      end

      def code_from_now
        Time.new(raw.from_now)
      end

      def inspect
        to_s
      end

      def to_s
        raw.to_s
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
code-ruby-0.8.2 lib/code/object/duration.rb
code-ruby-0.8.1 lib/code/object/duration.rb
code-ruby-0.8.0 lib/code/object/duration.rb
code-ruby-0.7.8 lib/code/object/duration.rb