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 |
# File 'lib/madman/item.rb', line 7 def initialize(path, type, basedir) @path, @type, @basedir = path, type, 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
19 20 21 |
# File 'lib/madman/item.rb', line 19 def dir? type == :dir end |
#file? ⇒ Boolean
23 24 25 |
# File 'lib/madman/item.rb', line 23 def file? type == :file end |
#href ⇒ Object
15 16 17 |
# File 'lib/madman/item.rb', line 15 def href Addressable::URI.escape(path_without_extension.sub(/^#{basedir}\//, '')) end |
#label ⇒ Object
11 12 13 |
# File 'lib/madman/item.rb', line 11 def label @label ||= File.basename(path_without_extension) end |