Class: Madman::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/madman/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#basedirObject (readonly)

Returns the value of attribute basedir.



5
6
7
# File 'lib/madman/item.rb', line 5

def basedir
  @basedir
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/madman/item.rb', line 5

def path
  @path
end

#typeObject (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

Returns:

  • (Boolean)


19
20
21
# File 'lib/madman/item.rb', line 19

def dir?
  type == :dir
end

#file?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/madman/item.rb', line 23

def file?
  type == :file
end

#hrefObject



15
16
17
# File 'lib/madman/item.rb', line 15

def href
  Addressable::URI.escape(path_without_extension.sub(/^#{basedir}\//, ''))
end

#labelObject



11
12
13
# File 'lib/madman/item.rb', line 11

def label
  @label ||= File.basename(path_without_extension)
end