class CW::BookDetails
Constants
- BOOK_DIR
- BOOK_NAME
- USER_BOOK_DEFAULT_DIR
Attributes
args[R]
Public Instance Methods
arguments(args)
click to toggle source
# File lib/cw/book_details.rb, line 39 def arguments args @args = args @args[:output] = :letter unless @args[:output] if @args[:duration] @timeout = Time.now + @args[:duration] * 60.0 end end
book_dir()
click to toggle source
# File lib/cw/book_details.rb, line 26 def book_dir @book_dir ||= Cfg.config["book_dir"] ? File.join(WORK_DIR, Cfg.config["book_dir"]) : is_user_book_default_dir? ? USER_BOOK_DEFAULT_DIR : BOOK_DIR end
book_location()
click to toggle source
# File lib/cw/book_details.rb, line 35 def book_location File.expand_path(book_name, book_dir) end
book_name()
click to toggle source
# File lib/cw/book_details.rb, line 15 def book_name @book_name ||= Cfg.config["book_name"] ? Cfg.config["book_name"] : BOOK_NAME end
book_timeout?()
click to toggle source
# File lib/cw/book_details.rb, line 63 def book_timeout? @timeout && (Time.now > @timeout) end
is_user_book_default_dir?()
click to toggle source
# File lib/cw/book_details.rb, line 22 def is_user_book_default_dir? File.exists? USER_BOOK_DEFAULT_DIR end
sentences_complete?()
click to toggle source
# File lib/cw/book_details.rb, line 51 def sentences_complete? if @args.has_key?(:sentences) && @args[:sentences].is_a?(1.class) if @sentence_count_source @sentence_count_source = nil else @args[:sentences] -= 1 @sentence_count_source = true end true if(@args[:sentences] < 0) end end
session_finished?()
click to toggle source
# File lib/cw/book_details.rb, line 47 def session_finished? sentences_complete? || book_timeout? end