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'.freeze
- LANG_SEP =
'-'.freeze
Instance Attribute Summary collapse
-
#dir ⇒ Object
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.
31 32 33 |
# File 'lib/codeless_code/fable_set.rb', line 31 def initialize(dir) self.dir = dir end |
Instance Attribute Details
#dir ⇒ Object
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
#fables ⇒ Object
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 |
#lang ⇒ Object
35 36 37 |
# File 'lib/codeless_code/fable_set.rb', line 35 def lang @lang ||= name_parts.first.to_sym end |
#translator ⇒ Object
39 40 41 |
# File 'lib/codeless_code/fable_set.rb', line 39 def translator @translator ||= name_parts.last end |