Class: Garb::Management::Segment

Inherits:
Object
  • Object
show all
Defined in:
lib/garb/management/segment.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#definitionObject

Returns the value of attribute definition.



5
6
7
# File 'lib/garb/management/segment.rb', line 5

def definition
  @definition
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/garb/management/segment.rb', line 5

def id
  @id
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/garb/management/segment.rb', line 5

def name
  @name
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/garb/management/segment.rb', line 4

def path
  @path
end

#sessionObject

Returns the value of attribute session.



4
5
6
# File 'lib/garb/management/segment.rb', line 4

def session
  @session
end

Class Method Details

.all(session = Session) ⇒ Object



7
8
9
10
# File 'lib/garb/management/segment.rb', line 7

def self.all(session = Session)
  feed = Feed.new(session, '/segments')
  feed.entries.map {|entry| new_from_entry(entry, session)}
end

.new_from_entry(entry, session) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/garb/management/segment.rb', line 12

def self.new_from_entry(entry, session)
  segment = new
  segment.session = session
  segment.path = Garb.parse_link(entry, "self").gsub(Feed::BASE_URL, '')
  segment.properties = entry['dxp:segment']
  segment
end

Instance Method Details

#properties=(properties) ⇒ Object



20
21
22
23
24
# File 'lib/garb/management/segment.rb', line 20

def properties=(properties)
  self.id = properties['id']
  self.name = properties['name']
  self.definition = properties['dxp:definition']
end