Class: Broadway::Definition::Link

Inherits:
Object
  • Object
show all
Defined in:
lib/broadway/processors/link.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site, context, &block) ⇒ Link

Returns a new instance of Link.



6
7
8
9
10
11
# File 'lib/broadway/processors/link.rb', line 6

def initialize(site, context, &block)
  self.site = site
  self.context = context
  self.records =  []
  instance_eval(&block)
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



4
5
6
# File 'lib/broadway/processors/link.rb', line 4

def context
  @context
end

#recordsObject

Returns the value of attribute records.



4
5
6
# File 'lib/broadway/processors/link.rb', line 4

def records
  @records
end

#siteObject

Returns the value of attribute site.



4
5
6
# File 'lib/broadway/processors/link.rb', line 4

def site
  @site
end

Instance Method Details



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/broadway/processors/link.rb', line 13

def link(*args, &block)
  options = args.extract_options!
  href = args.shift
  title = args.shift || options[:title] || href.split("/").last.titleize
  record = Broadway::Link.new(site, :href => href, :title => title, :categories => [context.to_s])
  self.records << record
  site.links << record
  if block_given?
    record.children = Broadway::Definition::Link.new(site, context, &block).records
  end
end