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

- (Object) definition

Returns the value of attribute definition



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

def definition
  @definition
end

- (Object) id

Returns the value of attribute id



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

def id
  @id
end

- (Object) name

Returns the value of attribute name



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

def name
  @name
end

- (Object) path

Returns the value of attribute path



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

def path
  @path
end

- (Object) session

Returns the value of attribute session



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

def session
  @session
end

Class Method Details

+ (Object) all(session = Session)



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

+ (Object) new_from_entry(entry, session)



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

- (Object) properties=(properties)



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