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'
LANG_SEP =
'-'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ FableSet


33
34
35
# File 'lib/codeless_code/fable_set.rb', line 33

def initialize(dir)
  @dir = dir
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir


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

def dir
  @dir
end

Instance Method Details

#fablesObject


45
46
47
# File 'lib/codeless_code/fable_set.rb', line 45

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

#filter(filt) ⇒ Object


49
50
51
# File 'lib/codeless_code/fable_set.rb', line 49

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

#langObject


37
38
39
# File 'lib/codeless_code/fable_set.rb', line 37

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

#translatorObject


41
42
43
# File 'lib/codeless_code/fable_set.rb', line 41

def translator
  @translator ||= name_parts.last
end