Class: Yarrow::Web::Document
- Inherits:
-
Object
- Object
- Yarrow::Web::Document
- Defined in:
- lib/yarrow/web/document.rb
Instance Method Summary collapse
-
#initialize(item, parent, is_index) ⇒ Document
constructor
This class is somewhat verbose for simplicity and long-term maintainability (having a clear and easy to follow construction, rather than doing anything too clever which has burned this lib in the past).
- #name ⇒ Object
- #title ⇒ Object
- #type ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(item, parent, is_index) ⇒ Document
This class is somewhat verbose for simplicity and long-term maintainability (having a clear and easy to follow construction, rather than doing anything too clever which has burned this lib in the past).
7 8 9 10 11 |
# File 'lib/yarrow/web/document.rb', line 7 def initialize(item, parent, is_index) @item = item @parent = parent @is_index = is_index end |
Instance Method Details
#name ⇒ Object
13 14 15 |
# File 'lib/yarrow/web/document.rb', line 13 def name @item.props[:name] end |
#title ⇒ Object
17 18 19 |
# File 'lib/yarrow/web/document.rb', line 17 def title @item.props[:title] end |
#type ⇒ Object
21 22 23 |
# File 'lib/yarrow/web/document.rb', line 21 def type @item.props[:type] end |
#url ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/yarrow/web/document.rb', line 25 def url if @parent.nil? "/" else segments = [@item.props[:name]] current = @parent until current.in(:collection).first.nil? do segments << current.props[:name] current = current.in(:collection).first end "/" + segments.reverse.join("/") end end |