Class: Archdown::Library

Inherits:
Object
  • Object
show all
Defined in:
lib/archdown/library.rb

Overview

The Library knows about its locations for books (e.g. file directory)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Library

Returns a new instance of Library.



6
7
8
# File 'lib/archdown/library.rb', line 6

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/archdown/library.rb', line 4

def path
  @path
end

Instance Method Details

#first(identifier) ⇒ Object



10
11
12
# File 'lib/archdown/library.rb', line 10

def first(identifier)
  identifier[0..1].downcase
end

#last(identifier) ⇒ Object



14
15
16
# File 'lib/archdown/library.rb', line 14

def last(identifier)
  identifier[-2..-1].downcase
end

#path_for_identifier(identifier, *parts) ⇒ Object



18
19
20
# File 'lib/archdown/library.rb', line 18

def path_for_identifier(identifier, *parts)
  File.join(path, first(identifier), last(identifier), identifier, *parts)
end