Sha256: 777e10ff7e1764dde34cd9011406202983026bc9756589b1ceddcbaf3cc80b49
Contents?: true
Size: 839 Bytes
Versions: 2
Compression:
Stored size: 839 Bytes
Contents
# frozen_string_literal: true require 'date' require 'time' module Roko module Source # @!attribute start # @return [Time] start time of this report # @!attribute end # @return [Time] end time of this report module Configurable attr_accessor :start, :end def setup(options) today = Date.today @start = parse_time_or_nil(options[:from]) || today.to_time @end = parse_time_or_nil(options[:to]) || today.next.to_time end # @param configurable [Roko::Source::Configurable] def configure_with(configurable) @start = configurable.start @end = configurable.end end private def parse_time_or_nil(str) Time.parse(str) rescue ArgumentError nil rescue TypeError nil end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
roko-0.2.1 | lib/roko/source/configurable.rb |
roko-0.2.0 | lib/roko/source/configurable.rb |