This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Device | |
include Toy::Store | |
attribute :device_adapter_id, String | |
def device_adapter | |
@device_adapter || load_device_adapter | |
end | |
def device_adapter=(device_adapter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Preset | |
include Toy::Store | |
attribute :target_value, Hash | |
attribute :device_ids, Array | |
def add_device(device) | |
raise "Device not persisted" unless device.persisted? | |
device_ids << device.id | |
target_value[device.id] = filtered_attributes(device) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'huey' | |
class Adapter::HueAdapter < Adapter::Base | |
creator "Nick Rowe" | |
adapts_to "Philips Hue Lighting System" | |
website "http://github.com/nixterrimus/hue-spirit-adapter" | |
implements :colorable_light |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'huey' | |
class Adapter::HueAdapter < Adapter::Base | |
creator "Nick Rowe" | |
adapts_to "Philips Hue Lighting System" | |
website "http://github.com/nixterrimus/hue-spirit-adapter" | |
implements :colorable_light |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'huey' | |
class Adapter::HueAdapter < Adapter::Base | |
creator "Nick Rowe" | |
adapts_to "Philips Hue Lighting System" | |
website "http://github.com/nixterrimus/hue-spirit-adapter" | |
implements :colorable_light |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'redis' | |
require 'celluloid' | |
require 'json' | |
require 'pry' | |
class Ticker | |
attr_reader :redis | |
attr_reader :channel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Huey | |
# An actual object for a bulb. | |
class Bulb | |
# ... | |
def self.find(identifier) | |
self.find_by_id(identifier) || self.find_by_name(identifier) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class.constants.reject { |klass_name| !includes_toy_store?(klass_name) }.collect { |klass_name| Kernel.const_get(klass_name) } | |
def includes_toy_store?(klass_name) | |
klass = Kernel.const_get(klass_name) | |
return false unless klass.respond_to? :included_modules | |
klass.included_modules.include?(Toy::Store) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"name": "Device", | |
"id": "a1f11592-823b-11e2-8ae1-fd12a6ecbbf6" | |
}, | |
{ | |
"name": "Device", | |
"id": "0b527208-823f-11e2-983a-034c1dac2e33" | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Find all of the square roots from 1 to 10 and log them to the console | |
function sqrt(x: number): number { | |
function square(x: number): number { | |
return x * x; | |
} | |
function average(x1: number, x2: number): number { | |
return (x1 + x2) / 2; | |
} |