Class: Lotus::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/lotus/generator.rb

Overview

The generator element identifies the agent used to generate the feed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Generator

Creates a representation of a generator.

options:

:base    => Optional base URI for use with a relative URI in uri.
:lang    => Optional string identifying the language of the name field.
:uri     => Optional string identifying the URL that SHOULD produce
            a representation that is relevant to the agent.
:version => Optional string indicating the version of the generating
            agent.
:name    => Optional name of the agent.


34
35
36
37
38
39
40
# File 'lib/lotus/generator.rb', line 34

def initialize(options = {})
  @base    = options[:base]
  @lang    = options[:lang]
  @uri     = options[:uri]
  @version = options[:version]
  @name    = options[:name]
end

Instance Attribute Details

#baseObject (readonly)

Holds the base URI for relative URIs contained in uri.



5
6
7
# File 'lib/lotus/generator.rb', line 5

def base
  @base
end

#langObject (readonly)

Holds the language of the name, when it exists. The language should be specified as RFC 3066 as either 2 or 3 letter codes. For example: ‘en’ for English or more specifically ‘en-us’



10
11
12
# File 'lib/lotus/generator.rb', line 10

def lang
  @lang
end

#nameObject (readonly)

Holds the string that provides a human-readable name that identifies the generating agent. The content of this field is language sensitive.



22
23
24
# File 'lib/lotus/generator.rb', line 22

def name
  @name
end

#uriObject (readonly)

Holds the optional uri that SHOULD produce a representation that is relevant to the agent.



14
15
16
# File 'lib/lotus/generator.rb', line 14

def uri
  @uri
end

#versionObject (readonly)

Holds the optional string identifying the version of the generating agent.



18
19
20
# File 'lib/lotus/generator.rb', line 18

def version
  @version
end

Instance Method Details

#to_hashObject

Yields a hash that represents the generator.



43
44
45
46
47
48
49
50
51
# File 'lib/lotus/generator.rb', line 43

def to_hash
  {
    :base    => self.base,
    :lang    => self.lang,
    :version => self.version,
    :uri     => self.uri,
    :name    => self.name
  }
end