Class: X::Entry
- Inherits:
-
Object
- Object
- X::Entry
- Defined in:
- lib/rfid-usb-gom-sensor/node.rb
Instance Attribute Summary collapse
-
#mtime ⇒ Object
Returns the value of attribute mtime.
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data = nil) ⇒ Entry
constructor
A new instance of Entry.
- #to_s ⇒ Object
Constructor Details
#initialize(data = nil) ⇒ Entry
Returns a new instance of Entry.
11 12 13 |
# File 'lib/rfid-usb-gom-sensor/node.rb', line 11 def initialize data = nil @data = data end |
Instance Attribute Details
#mtime ⇒ Object
Returns the value of attribute mtime.
10 11 12 |
# File 'lib/rfid-usb-gom-sensor/node.rb', line 10 def mtime @mtime end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/rfid-usb-gom-sensor/node.rb', line 10 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
10 11 12 |
# File 'lib/rfid-usb-gom-sensor/node.rb', line 10 def path @path end |
Class Method Details
.find(path, recurse = 0) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rfid-usb-gom-sensor/node.rb', line 31 def self.find path, recurse = 0 json = (Gom::Remote.connection.read "#{path}.json") clazz, key = /:/.match(path) ? [Attribute, "attribute"] : [Node, "node"] a = clazz.new JSON.parse(json)[key] a =begin json = (connection.read "#{path}.json") (JSON.parse json)["node"]["entries"].select do |entry| # 1. select attribute entries entry.has_key? "attribute" end.inject({}) do |h, a| # 2. make it a key, value list h[a["attribute"]["name"].to_sym] = a["attribute"]["value"] h end =end end |
Instance Method Details
#to_s ⇒ Object
27 28 29 |
# File 'lib/rfid-usb-gom-sensor/node.rb', line 27 def to_s "name: #{name}\npath: #{path}\nmtime: #{mtime}" end |