Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress Ruby interpreter warnings #381

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/chronic/repeaters/repeater_quarter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ class RepeaterQuarter < Repeater #:nodoc:
MONTHS_PER_QUARTER = 3
QUARTER_SECONDS = 7_776_000 # 3 * 30 * 24 * 60 * 60

def initialize(type, width = nil, options = {})
@current_span = nil

super
end

def next(pointer)
@current_span ||= quarter(@now)
offset_quarter_amount = pointer == :future ? 1 : -1
Expand Down
32 changes: 16 additions & 16 deletions lib/chronic/tags/scalar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ def self.scan(tokens, options)
token = tokens[i]
post_token = tokens[i + 1]
if token.word =~ /^\d+$/
width = token.word.length
scalar = token.word.to_i
token.tag(Scalar.new(scalar, width))
token.tag(ScalarWide.new(token.word, width)) if width == 4
token.tag(ScalarSubsecond.new(scalar, width)) if Chronic::Time::could_be_subsecond?(scalar, width)
token.tag(ScalarSecond.new(scalar, width)) if Chronic::Time::could_be_second?(scalar, width)
token.tag(ScalarMinute.new(scalar, width)) if Chronic::Time::could_be_minute?(scalar, width)
token.tag(ScalarHour.new(scalar, width)) if Chronic::Time::could_be_hour?(scalar, width, options[:hours24] == false)
unless post_token and DAY_PORTIONS.include?(post_token.word)
token.tag(ScalarDay.new(scalar, width)) if Chronic::Date::could_be_day?(scalar, width)
token.tag(ScalarMonth.new(scalar, width)) if Chronic::Date::could_be_month?(scalar, width)
if Chronic::Date::could_be_year?(scalar, width)
year = Chronic::Date::make_year(scalar, options[:ambiguous_year_future_bias])
token.tag(ScalarYear.new(year.to_i, width))
end
width = token.word.length
scalar = token.word.to_i
token.tag(Scalar.new(scalar, width))
token.tag(ScalarWide.new(token.word, width)) if width == 4
token.tag(ScalarSubsecond.new(scalar, width)) if Chronic::Time::could_be_subsecond?(scalar, width)
token.tag(ScalarSecond.new(scalar, width)) if Chronic::Time::could_be_second?(scalar, width)
token.tag(ScalarMinute.new(scalar, width)) if Chronic::Time::could_be_minute?(scalar, width)
token.tag(ScalarHour.new(scalar, width)) if Chronic::Time::could_be_hour?(scalar, width, options[:hours24] == false)
unless post_token and DAY_PORTIONS.include?(post_token.word)
token.tag(ScalarDay.new(scalar, width)) if Chronic::Date::could_be_day?(scalar, width)
token.tag(ScalarMonth.new(scalar, width)) if Chronic::Date::could_be_month?(scalar, width)
if Chronic::Date::could_be_year?(scalar, width)
year = Chronic::Date::make_year(scalar, options[:ambiguous_year_future_bias])
token.tag(ScalarYear.new(year.to_i, width))
end
end
end
end
Expand Down Expand Up @@ -86,4 +86,4 @@ def to_s
super << '-year-' << @type.to_s
end
end
end
end