class Verkilo::Shelf

Public Class Methods

new(root_dir) click to toggle source
# File lib/verkilo/shelf.rb, line 3
def initialize(root_dir)
  cmd = "basename -s .git `git config --get remote.origin.url`"
  @repo = `#{cmd}`.strip || root_dir
  @root_dir = root_dir
  @books = []
  @wordcount = Hash.new
end

Public Instance Methods

books() click to toggle source
# File lib/verkilo/shelf.rb, line 23
def books
  return @books unless @books.empty?
  @books = Dir["#{@root_dir}/**/.book"].map do |book_flag|
    dir = File.dirname(book_flag)
    title = File.basename(dir)
    Book.new(title, dir, @repo)
  end
end
title()
Alias for: to_s
to_i() click to toggle source
# File lib/verkilo/shelf.rb, line 15
def to_i
  self.books.each do |b|
    @wordcount[b.title] = b.to_i
  end
  return @wordcount
end
Also aliased as: wordcount
to_s() click to toggle source
# File lib/verkilo/shelf.rb, line 10
def to_s
  File.basename(@root_dir)
end
Also aliased as: title
wordcount()
Alias for: to_i