Skip to content

Commit

Permalink
Fix remaining errors
Browse files Browse the repository at this point in the history
  • Loading branch information
soffes committed Jan 3, 2024
1 parent 9f3f9a1 commit 33a9df1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions lib/hue/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def initialize(username = nil, use_mdns: true)
def bridge
@bridge_id ||= find_bridge_id
bridge = if @bridge_id
bridges.select { |b| b.id == @bridge_id }.first
bridges.find { |b| b.id == @bridge_id }
else
bridges.first
end
Expand All @@ -52,7 +52,7 @@ def add_lights

def light(id)
id = id.to_s
lights.select { |l| l.id == id }.first
lights.find { |l| l.id == id }
end

def groups
Expand All @@ -63,7 +63,7 @@ def group(id = nil)
return Group.new(self, bridge) if id.nil?

id = id.to_s
groups.select { |g| g.id == id }.first
groups.find { |g| g.id == id }
end

def scenes
Expand All @@ -72,7 +72,7 @@ def scenes

def scene(id)
id = id.to_s
scenes.select { |s| s.id == id }.first
scenes.find { |s| s.id == id }
end

private
Expand All @@ -93,7 +93,7 @@ def validate_user
response = response.first
end

if error = response["error"]
if (error = response["error"])
raise get_error(error)
end

Expand All @@ -109,11 +109,11 @@ def register_user
http = Net::HTTP.new(uri.host)
response = JSON(http.request_post(uri.path, body).body).first

if error = response["error"]
if (error = response["error"])
raise get_error(error)
end

if @username = response["success"]["username"]
if (@username = response["success"]["username"])
File.write(File.expand_path("~/.hue"), JSON.dump({username: @username}))
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/hue/light.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def initialize(client, bridge, id, hash)
end

def name=(new_name)
unless (1..32).include?(new_name.length)
unless (1..32).cover?(new_name.length)
raise InvalidValueForParameter, "name must be between 1 and 32 characters."
end

Expand Down Expand Up @@ -132,7 +132,7 @@ def set_state(attributes, transition = nil)
body = translate_keys(attributes, STATE_KEYS_MAP)

# Add transition
body.merge!({transitiontime: transition}) if transition
body[:transitiontime] = transition if transition

uri = URI.parse("#{base_url}/state")
http = Net::HTTP.new(uri.host)
Expand Down

0 comments on commit 33a9df1

Please sign in to comment.