Class: XTeamSchedule
- Inherits:
-
Object
show all
- Defined in:
- lib/xteam_schedule/core.rb
Defined Under Namespace
Classes: Assignment, AssignmentGroup, Base, Composer, Holiday, IO, Interface, Parser, Resource, ResourceGroup, Schedule, Schema, WeeklyWorkingSchedule, WorkingDay, WorkingTime
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(hash_or_filename = nil) ⇒ XTeamSchedule
Returns a new instance of XTeamSchedule.
3
4
5
6
7
8
9
10
|
# File 'lib/xteam_schedule/core.rb', line 3
def initialize(hash_or_filename = nil)
if hash_or_filename.present?
hash = hash_or_filename.class == Hash ? hash_or_filename : IO.read(hash_or_filename)
@schedule = Parser.parse(hash)
else
@schedule = Schedule.create!
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args) ⇒ Object
21
22
23
|
# File 'lib/xteam_schedule/core.rb', line 21
def method_missing(*args);
@schedule.send(*args)
end
|
Class Method Details
.inspect ⇒ Object
25
26
27
|
# File 'lib/xteam_schedule/core.rb', line 25
def self.inspect
XTeamSchedule::Schedule.inspect
end
|
Instance Method Details
#hash ⇒ Object
17
18
19
|
# File 'lib/xteam_schedule/core.rb', line 17
def hash
Composer.compose(self)
end
|
#inspect ⇒ Object
29
30
31
32
33
|
# File 'lib/xteam_schedule/core.rb', line 29
def inspect
stats = [:resource_groups, :resources, :assignment_groups, :assignments, :working_times].map { |s| [s, send(s).count] }
stats_string = stats.map { |s| "#{s.first}(#{s.second})" }.join(', ')
"#<XTeamSchedule #{stats_string}>"
end
|
#write(filename) ⇒ Object
12
13
14
15
|
# File 'lib/xteam_schedule/core.rb', line 12
def write(filename)
raise 'No filename provided' unless filename.present?
IO.write(hash, filename)
end
|