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
10
11
# File 'lib/madman/item.rb', line 7

def initialize(path, type, basedir)
  @path = path
  @type = type
  @basedir = 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)


21
22
23
# File 'lib/madman/item.rb', line 21

def dir?
  type == :dir
end

#file?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/madman/item.rb', line 25

def file?
  type == :file
end

#hrefObject



17
18
19
# File 'lib/madman/item.rb', line 17

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

#labelObject



13
14
15
# File 'lib/madman/item.rb', line 13

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