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

Calibrate method privacy #120

Merged
merged 1 commit into from
Jun 6, 2018
Merged
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
2 changes: 1 addition & 1 deletion lib/biz/calculation/active.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def result
&& schedule.holidays.none? { |holiday| holiday.contains?(time) }
end

protected
private

attr_reader :schedule,
:time
Expand Down
4 changes: 1 addition & 3 deletions lib/biz/calculation/for_duration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,11 @@ def initialize(schedule, scalar)
fail ArgumentError, 'negative scalar' if @scalar.negative?
end

protected
private

attr_reader :schedule,
:scalar

private

def unit
self.class.unit
end
Expand Down
2 changes: 1 addition & 1 deletion lib/biz/calculation/on_break.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def result
schedule.breaks.any? { |brake| brake.contains?(time) }
end

protected
private

attr_reader :schedule,
:time
Expand Down
2 changes: 1 addition & 1 deletion lib/biz/calculation/on_holiday.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def result
schedule.holidays.any? { |holiday| holiday.contains?(time) }
end

protected
private

attr_reader :schedule,
:time
Expand Down
2 changes: 2 additions & 0 deletions lib/biz/day_of_week.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def wday?(other_wday)
wday == other_wday
end

private

def <=>(other)
return unless other.is_a?(self.class)

Expand Down
12 changes: 6 additions & 6 deletions lib/biz/day_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,18 @@ def timestamp
format(Timestamp::FORMAT, hour, minute)
end

def <=>(other)
return unless other.is_a?(self.class)

day_second <=> other.day_second
end

private

def valid_second?
VALID_SECONDS.cover?(day_second)
end

def <=>(other)
return unless other.is_a?(self.class)

day_second <=> other.day_second
end

MIDNIGHT = from_hour(0)
ENDNIGHT = from_hour(24)

Expand Down
10 changes: 6 additions & 4 deletions lib/biz/duration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,17 @@ def abs
self.class.new(seconds.abs)
end

protected

attr_reader :seconds

private

def <=>(other)
return unless other.is_a?(self.class)

seconds <=> other.seconds
end

protected

attr_reader :seconds

end
end
14 changes: 8 additions & 6 deletions lib/biz/holiday.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ def to_time_segment
end
end

def <=>(other)
return unless other.is_a?(self.class)

[date, time_zone] <=> [other.date, other.time_zone]
end

protected

attr_reader :date,
Expand All @@ -40,5 +34,13 @@ def to_date
date
end

private

def <=>(other)
return unless other.is_a?(self.class)

[date, time_zone] <=> [other.date, other.time_zone]
end

end
end
2 changes: 2 additions & 0 deletions lib/biz/interval.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def &(other)
self.class.new(lower_bound, [lower_bound, upper_bound].max, time_zone)
end

private

def <=>(other)
return unless other.is_a?(self.class)

Expand Down
4 changes: 1 addition & 3 deletions lib/biz/periods/abstract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ def timeline
Timeline::Proxy.new(self)
end

protected
private

attr_reader :schedule,
:origin

private

def periods
weeks
.lazy
Expand Down
2 changes: 1 addition & 1 deletion lib/biz/periods/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def on(date)
.until(schedule.in_zone.on_date(date, DayTime.endnight))
end

protected
private

attr_reader :schedule

Expand Down
2 changes: 1 addition & 1 deletion lib/biz/time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def during_week(week, week_time)
on_date(week.start_date + week_time.wday, week_time.day_time)
end

protected
private

attr_reader :time_zone

Expand Down
2 changes: 2 additions & 0 deletions lib/biz/time_segment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def /(other)
].reject(&:empty?).map { |potential| self & potential }
end

private

def <=>(other)
return unless other.is_a?(self.class)

Expand Down
2 changes: 1 addition & 1 deletion lib/biz/timeline/abstract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def for(duration)
end
end

protected
private

attr_reader :periods

Expand Down
2 changes: 1 addition & 1 deletion lib/biz/timeline/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def backward
Backward.new(periods)
end

protected
private

attr_reader :periods

Expand Down
4 changes: 2 additions & 2 deletions lib/biz/validation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def perform
self
end

protected
private

attr_reader :raw

Expand All @@ -32,7 +32,7 @@ def check(raw)
fail Error::Configuration, message unless condition.call(raw)
end

protected
private

attr_reader :message,
:condition
Expand Down
10 changes: 6 additions & 4 deletions lib/biz/week.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@ def +(other)
self.class.new(week + other.week)
end

protected

attr_reader :week

private

def <=>(other)
return unless other.is_a?(self.class)

week <=> other.week
end

protected

attr_reader :week

end
end
10 changes: 6 additions & 4 deletions lib/biz/week_time/abstract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,18 @@ def wday_symbol
timestamp
] => :day_time

protected

attr_reader :week_minute

private

def <=>(other)
return unless other.is_a?(WeekTime::Abstract)

week_minute <=> other.week_minute
end

protected

attr_reader :week_minute

end
end
end