Class: TimeOverlap::Calculator
- Inherits:
-
Object
- Object
- TimeOverlap::Calculator
- Defined in:
- lib/time_overlap/calculator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(from:, to:, time_zone:, my_time_zone:, min_overlap:, expert: true, show_base: true) ⇒ Calculator
constructor
A new instance of Calculator.
Constructor Details
#initialize(from:, to:, time_zone:, my_time_zone:, min_overlap:, expert: true, show_base: true) ⇒ Calculator
Returns a new instance of Calculator.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/time_overlap/calculator.rb', line 4 def initialize(from:, to:, time_zone:, my_time_zone:, min_overlap:, expert: true, show_base: true) @current_year = Time.current.year @current_month = Time.current.month @current_day = Time.current.day @from = from @to = to @time_zone = time_zone @my_time_zone = my_time_zone @min_overlap = min_overlap @start_time = set_time(from) @end_time = set_time(to) @duration = (end_time - start_time).to_i / 60 / 60 @expert = expert @show_base = show_base @data = {} end |
Class Method Details
.show(*args) ⇒ Object
24 25 26 |
# File 'lib/time_overlap/calculator.rb', line 24 def self.show(*args) self.new(*args).execute end |
Instance Method Details
#execute ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/time_overlap/calculator.rb', line 28 def execute @data = build_data if @data[:overlap_1][:start] == @data[:overlap_2][:start] && @data[:overlap_1][:end] == @data[:overlap_2][:end] @data.delete(:overlap_2) end throw_errors! unless @expert @data.delete(:overlap_1) @data.delete(:overlap_2) end present_result end |