Class: Madness::Item

Inherits:
Object
  • Object
show all
Includes:
ServerHelper
Defined in:
lib/madness/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.



8
9
10
11
# File 'lib/madness/item.rb', line 8

def initialize(path, type)
  @path = path
  @type = type
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/madness/item.rb', line 6

def path
  @path
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/madness/item.rb', line 6

def type
  @type
end

Instance Method Details

#dir?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/madness/item.rb', line 24

def dir?
  type == :dir
end

#file?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/madness/item.rb', line 28

def file?
  type == :file
end

#hrefObject



17
18
19
20
21
22
# File 'lib/madness/item.rb', line 17

def href
  @href ||= begin
    result = path_without_extension.sub(/^#{docroot}/, '').to_href
    "#{config.base_uri}#{result}"
  end
end

#labelObject



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

def label
  @label ||= label!
end