Module: Iot::BleYamlParser

Included in:
Iot
Defined in:
lib/iot/bleyamlparser.rb

Instance Method Summary collapse

Instance Method Details

#load_deviceinfoObject



8
9
10
# File 'lib/iot/bleyamlparser.rb', line 8

def load_deviceinfo
  # TODO
end

#load_yaml_bodyObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/iot/bleyamlparser.rb', line 12

def load_yaml_body
  yaml_path = File.expand_path Yaml_path

  if File.exist? yaml_path
    yaml_body = File.read yaml_path
    return YAML.load yaml_body
  else
    return ""
  end
end

#refresh_yaml_body(yaml) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/iot/bleyamlparser.rb', line 23

def refresh_yaml_body yaml
  yaml_path = File.expand_path Yaml_path
  File.open(yaml_path, "w") do |file|
    file = nil
  end
  new_yaml= YAML.dump yaml
  File.write(yaml_path, new_yaml)
end

#service_exist?(services, service_name) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
35
36
37
38
39
40
# File 'lib/iot/bleyamlparser.rb', line 32

def service_exist?(services, service_name)
  services.each do |service|
    if service["name"] == service_name
      return true
    end
  end

  return false
end