Class: SocialFramework::ScheduleHelper::ScheduleStrategyDefault
- Inherits:
-
ScheduleStrategy
- Object
- ScheduleStrategy
- SocialFramework::ScheduleHelper::ScheduleStrategyDefault
- Defined in:
- app/helpers/social_framework/schedule_helper.rb
Overview
Represent the schedule on a Graph, with Vertices and Edges
Instance Method Summary collapse
-
#initialize(elements_factory = ElementsFactoryDefault, max_duration = SocialFramework.max_duration_to_schedule_graph) ⇒ ScheduleStrategyDefault
constructor
- Init the slots and users in Array ====== Params:
elements_factory
String
Represent the factory class name to buildmax_duration
-
ActiveSupport::Duration
used to define max finish day to build graph Returns Graph’s Instance.
- Init the slots and users in Array ====== Params:
-
#verify_availabilities(users, start_day, finish_day, start_hour = Time.parse("00:00"), finish_hour = Time.parse("23:59"), slots_size = SocialFramework.slots_size) ⇒ Object
- Build slots to verify availabilities ====== Params:
users
Array
users to check disponibilitystart_day
Date
start day to get slotsfinish_day
Date
finish day to get slotsstart_hour
Time
start hour at each day to get slotsfinish_hour
Time
finish hour at each day to get slotsslots_size
-
Integer
slots size duration Returns The Graph mounted.
- Build slots to verify availabilities ====== Params:
Constructor Details
#initialize(elements_factory = ElementsFactoryDefault, max_duration = SocialFramework.max_duration_to_schedule_graph) ⇒ ScheduleStrategyDefault
Init the slots and users in Array
Params:
elements_factory
-
String
Represent the factory class name to build max_duration
-
ActiveSupport::Duration
used to define max finish day to build graph
Returns Graph’s Instance
40 41 42 43 44 45 |
# File 'app/helpers/social_framework/schedule_helper.rb', line 40 def initialize(elements_factory = ElementsFactoryDefault, max_duration = SocialFramework.max_duration_to_schedule_graph) super @users = Array.new @fixed_users = Array.new end |
Instance Method Details
#verify_availabilities(users, start_day, finish_day, start_hour = Time.parse("00:00"), finish_hour = Time.parse("23:59"), slots_size = SocialFramework.slots_size) ⇒ Object
Build slots to verify availabilities
Params:
users
-
Array
users to check disponibility start_day
-
Date
start day to get slots finish_day
-
Date
finish day to get slots start_hour
-
Time
start hour at each day to get slots finish_hour
-
Time
finish hour at each day to get slots slots_size
-
Integer
slots size duration
Returns The Graph mounted
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/helpers/social_framework/schedule_helper.rb', line 56 def verify_availabilities(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 |