Class: CodelessCode::FableSet
- Inherits:
-
Object
- Object
- CodelessCode::FableSet
- 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
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
Instance Method Summary collapse
- #fables ⇒ Object
- #filter(filt) ⇒ Object
-
#initialize(dir) ⇒ FableSet
constructor
A new instance of FableSet.
- #lang ⇒ Object
- #translator ⇒ Object
Constructor Details
#initialize(dir) ⇒ FableSet
Returns a new instance of FableSet.
33 34 35 |
# File 'lib/codeless_code/fable_set.rb', line 33 def initialize(dir) @dir = dir end |
Instance Attribute Details
#dir ⇒ Object (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
#fables ⇒ Object
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 |
#lang ⇒ Object
37 38 39 |
# File 'lib/codeless_code/fable_set.rb', line 37 def lang @lang ||= name_parts.first.to_sym end |
#translator ⇒ Object
41 42 43 |
# File 'lib/codeless_code/fable_set.rb', line 41 def translator @translator ||= name_parts.last end |