Class: Madman::Item
- Inherits:
-
Object
- Object
- Madman::Item
- Defined in:
- lib/madman/item.rb
Instance Attribute Summary collapse
-
#basedir ⇒ Object
readonly
Returns the value of attribute basedir.
-
#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, basedir) ⇒ Item
constructor
A new instance of Item.
- #label ⇒ Object
Constructor Details
#initialize(path, type, basedir) ⇒ Item
Returns a new instance of Item.
7 8 9 10 11 |
# File 'lib/madman/item.rb', line 7 def initialize(path, type, basedir) @path = path @type = type @basedir = basedir end |
Instance Attribute Details
#basedir ⇒ Object (readonly)
Returns the value of attribute basedir.
5 6 7 |
# File 'lib/madman/item.rb', line 5 def basedir @basedir end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/madman/item.rb', line 5 def path @path end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/madman/item.rb', line 5 def type @type end |
Instance Method Details
#dir? ⇒ Boolean
21 22 23 |
# File 'lib/madman/item.rb', line 21 def dir? type == :dir end |
#file? ⇒ Boolean
25 26 27 |
# File 'lib/madman/item.rb', line 25 def file? type == :file end |
#href ⇒ Object
17 18 19 |
# File 'lib/madman/item.rb', line 17 def href Addressable::URI.escape(path_without_extension.sub(%r{^#{basedir}/}, '')) end |
#label ⇒ Object
13 14 15 |
# File 'lib/madman/item.rb', line 13 def label @label ||= File.basename(path_without_extension) end |