Class: Madness::Item
- Inherits:
-
Object
- Object
- Madness::Item
- Includes:
- ServerHelper
- Defined in:
- lib/madness/item.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #dir? ⇒ Boolean
- #file? ⇒ Boolean
- #href ⇒ Object
-
#initialize(path, type) ⇒ Item
constructor
A new instance of Item.
- #label ⇒ Object
Methods included from ServerHelper
#config, #disallowed_static?, #docroot, #find_static_file, #log, #theme
Constructor Details
#initialize(path, type) ⇒ Item
Returns a new instance of Item.
10 11 12 13 |
# File 'lib/madness/item.rb', line 10 def initialize(path, type) @path = path @type = type end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
8 9 10 |
# File 'lib/madness/item.rb', line 8 def children @children end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/madness/item.rb', line 7 def path @path end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/madness/item.rb', line 7 def type @type end |
Instance Method Details
#dir? ⇒ Boolean
26 27 28 |
# File 'lib/madness/item.rb', line 26 def dir? type == :dir end |
#file? ⇒ Boolean
30 31 32 |
# File 'lib/madness/item.rb', line 30 def file? type == :file end |
#href ⇒ Object
19 20 21 22 23 24 |
# File 'lib/madness/item.rb', line 19 def href @href ||= begin result = path_without_extension.sub(/^#{docroot}/, '').to_href "#{config.base_uri}#{result}" end end |
#label ⇒ Object
15 16 17 |
# File 'lib/madness/item.rb', line 15 def label @label ||= label! end |