Class: Eeml::JsonEnvironmentParserV005

Inherits:
Object
  • Object
show all
Includes:
Exceptions
Defined in:
lib/eeml/json_environment_parser_v005.rb

Overview

A parser for json environments based on the EEML 5 specification.

Instance Method Summary collapse

Instance Method Details

#make_environment_from_hash(env_hash) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/eeml/json_environment_parser_v005.rb', line 6

def make_environment_from_hash(env_hash)
  env = Environment.new(:title => env_hash["title"],
                        :description => env_hash["description"],
                        :feed_url => env_hash["feed"],
                        :website => env_hash["website"],
                        :email => env_hash["email"],
                        :icon => env_hash["icon"],
                        :status => env_hash["status"],
                        :identifier => env_hash["id"],
                        :private => env_hash["private"].to_s == "true")

  env.updated = Time.gm(*ParseDate.parsedate(env_hash['updated'])) unless env_hash['updated'].nil?

  env.location = buildLocation(env_hash)

  env.add_datastreams(buildDatastreams(env_hash))
  
  return env
end

#make_environment_from_json(json_str) ⇒ Object



26
27
28
29
# File 'lib/eeml/json_environment_parser_v005.rb', line 26

def make_environment_from_json(json_str)
  env_hash = JSON.parse(strip_content(json_str))
  return make_environment_from_hash(env_hash)
end