Class: CodelessCode::FableSet

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/codeless_code/fable_set.rb

Overview

An collection of fables in a given language, all translated by the same person.

Constant Summary collapse

FILE_PATTERN =
'*.txt'.freeze
LANG_SEP =
'-'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ FableSet

Returns a new instance of FableSet.



31
32
33
# File 'lib/codeless_code/fable_set.rb', line 31

def initialize(dir)
  self.dir = dir
end

Instance Attribute Details

#dirObject

Returns the value of attribute dir.



28
29
30
# File 'lib/codeless_code/fable_set.rb', line 28

def dir
  @dir
end

Instance Method Details

#fablesObject



43
44
45
# File 'lib/codeless_code/fable_set.rb', line 43

def fables
  @fables ||= files.map { |f| Fable.new(f) }.sort_by(&:number)
end

#filter(filt) ⇒ Object



47
48
49
# File 'lib/codeless_code/fable_set.rb', line 47

def filter(filt)
  select { |f| filt.call(f) }
end

#langObject



35
36
37
# File 'lib/codeless_code/fable_set.rb', line 35

def lang
  @lang ||= name_parts.first.to_sym
end

#translatorObject



39
40
41
# File 'lib/codeless_code/fable_set.rb', line 39

def translator
  @translator ||= name_parts.last
end