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

first attempt for fix of hash failure of blackouts #226

Merged
merged 1 commit into from
Aug 26, 2016
Merged
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
first attempt for fix of hash failure of blackouts
  • Loading branch information
sgreen-r7 committed May 4, 2016
commit 5cc3b4dff3e9aba71b93b2ccb3338f5da86cc13d
20 changes: 14 additions & 6 deletions lib/nexpose/blackout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,25 @@ class Blackout < APIObject
attr_accessor :blackout_duration

def initialize(start, enabled=true, duration, type, interval)
@blackout_start = start
@enabled =enabled
@blackout_start = start
@enabled = enabled
@blackout_duration = duration.to_i
@blackout_type = type
@blackout_type = type
@blackout_interval = interval.to_i
end

def self.from_hash(hash)
repeat_blackout_hash = hash[:repeat_blackout]
blackout = new(hash[:start_date], hash[:blackout_duration], repeat_blackout_hash[:type], repeat_blackout_hash[:interval])
blackout

if repeat_blackout_hash.nil?
type = 'daily'
interval = 0
else
type = repeat_blackout_hash[:type]
interval = repeat_blackout_hash[:interval]
end

new(hash[:start_date], hash[:blackout_duration], type, interval)
end

def to_h
Expand All @@ -41,4 +49,4 @@ def to_h
blackout_hash
end
end
end
end