Class: SocialFramework::ScheduleHelper::Graph
- Inherits:
-
Object
- Object
- SocialFramework::ScheduleHelper::Graph
- Defined in:
- app/helpers/social_framework/schedule_helper.rb
Overview
Represent the schedule on a Graph, with Vertices and Edges
Instance Attribute Summary collapse
-
#slots ⇒ Object
Returns the value of attribute slots.
Instance Method Summary collapse
-
#build(users, start_day, finish_day, start_hour = Time.parse("00:00"), finish_hour = Time.parse("23:59"), slots_size = SocialFramework.slots_size) ⇒ Object
- Init the slots and users in Array ====== Params:
users Arrayusers to check disponibilitystart_dayDatestart day to get slotsfinish_dayDatefinish day to get slotsstart_hourTimestart hour at each day to get slotsfinish_hourTimefinish hour at each day to get slotsslots_size-
Integerslots size duration Returns The Graph mounted.
- Init the slots and users in Array ====== Params:
-
#initialize(max_duration = SocialFramework.max_duration_to_schedule_graph) ⇒ Graph
constructor
- Init the slots and users in Array ====== Params:
max_duration -
ActiveSupport::Durationused to define max finish day to build graph Returns Graph’s Instance.
- Init the slots and users in Array ====== Params:
Constructor Details
#initialize(max_duration = SocialFramework.max_duration_to_schedule_graph) ⇒ Graph
Init the slots and users in Array
Params:
max_duration-
ActiveSupport::Durationused to define max finish day to build graph
Returns Graph’s Instance
14 15 16 17 18 19 |
# File 'app/helpers/social_framework/schedule_helper.rb', line 14 def initialize max_duration = SocialFramework.max_duration_to_schedule_graph @slots = Array.new @users = Array.new @fixed_users = Array.new @max_duration = max_duration end |
Instance Attribute Details
#slots ⇒ Object
Returns the value of attribute slots.
8 9 10 |
# File 'app/helpers/social_framework/schedule_helper.rb', line 8 def slots @slots end |
Instance Method Details
#build(users, start_day, finish_day, start_hour = Time.parse("00:00"), finish_hour = Time.parse("23:59"), slots_size = SocialFramework.slots_size) ⇒ Object
Init the slots and users in Array
Params:
users-
Arrayusers to check disponibility start_day-
Datestart day to get slots finish_day-
Datefinish day to get slots start_hour-
Timestart hour at each day to get slots finish_hour-
Timefinish hour at each day to get slots slots_size-
Integerslots size duration
Returns The Graph mounted
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/helpers/social_framework/schedule_helper.rb', line 30 def build(users, start_day, finish_day, start_hour = Time.parse("00:00"), finish_hour = Time.parse("23:59"), slots_size = SocialFramework.slots_size) return unless finish_day_ok? start_day, finish_day @slots_size = slots_size start_time = start_day.to_datetime + start_hour.seconds_since_midnight.seconds finish_time = finish_day.to_datetime + finish_hour.seconds_since_midnight.seconds build_users(users) build_slots(start_time, finish_time, start_hour, finish_hour) unless @fixed_users.empty? build_edges(@fixed_users, start_time, finish_time) @slots.select! { |slot| slot.edges.count == @fixed_users.count } end build_edges(@users, start_time, finish_time) @slots.sort_by! { |slot| -slot.attributes[:gained_weight] } end |