Class: CodelessCode::Fable
- Inherits:
-
Object
- Object
- CodelessCode::Fable
- Extended by:
- Forwardable
- Defined in:
- lib/codeless_code/fable.rb
Constant Summary collapse
- HEADER_PATTERN =
/([^:\s]+)\s*:\s*(.+)\s*$/.freeze
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
Instance Method Summary collapse
- #body ⇒ Object (also: #to_s)
- #credits ⇒ Object
- #date ⇒ Object
- #geekiness ⇒ Object
- #header?(key) ⇒ Boolean
- #headers ⇒ Object
-
#initialize(file) ⇒ Fable
constructor
A new instance of Fable.
- #lang ⇒ Object
- #names ⇒ Object
- #number ⇒ Object
-
#read_headers? ⇒ Object
Returns the value of attribute read_headers.
- #tagline ⇒ Object
- #title ⇒ Object
- #topics ⇒ Object
- #translator ⇒ Object
Constructor Details
#initialize(file) ⇒ Fable
Returns a new instance of Fable.
31 32 33 34 35 |
# File 'lib/codeless_code/fable.rb', line 31 def initialize(file) self.file = file @read_headers = false @body_pos = nil end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
25 26 27 |
# File 'lib/codeless_code/fable.rb', line 25 def file @file end |
Instance Method Details
#body ⇒ Object Also known as: to_s
37 38 39 |
# File 'lib/codeless_code/fable.rb', line 37 def body @body ||= read_body.freeze end |
#credits ⇒ Object
73 74 75 |
# File 'lib/codeless_code/fable.rb', line 73 def credits self['Credits'] end |
#date ⇒ Object
53 54 55 |
# File 'lib/codeless_code/fable.rb', line 53 def date ::Date.parse(self['Date']) if header?('Date') end |
#geekiness ⇒ Object
81 82 83 |
# File 'lib/codeless_code/fable.rb', line 81 def geekiness self['Geekiness'].to_i end |
#header?(key) ⇒ Boolean
49 50 51 |
# File 'lib/codeless_code/fable.rb', line 49 def header?(key) headers.key?(key) end |
#headers ⇒ Object
42 43 44 45 46 47 |
# File 'lib/codeless_code/fable.rb', line 42 def headers @headers ||= begin @read_headers = true read_headers.freeze end end |
#lang ⇒ Object
57 58 59 |
# File 'lib/codeless_code/fable.rb', line 57 def lang @lang ||= dir_parts.first.to_sym end |
#names ⇒ Object
85 86 87 |
# File 'lib/codeless_code/fable.rb', line 85 def names list('Names') end |
#number ⇒ Object
77 78 79 |
# File 'lib/codeless_code/fable.rb', line 77 def number self['Number'].to_i end |
#read_headers? ⇒ Object
Returns the value of attribute read_headers.
28 29 30 |
# File 'lib/codeless_code/fable.rb', line 28 def read_headers @read_headers end |
#tagline ⇒ Object
69 70 71 |
# File 'lib/codeless_code/fable.rb', line 69 def tagline self['Tagline'] end |
#title ⇒ Object
65 66 67 |
# File 'lib/codeless_code/fable.rb', line 65 def title self['Title'] end |
#topics ⇒ Object
89 90 91 |
# File 'lib/codeless_code/fable.rb', line 89 def topics list('Topics') end |
#translator ⇒ Object
61 62 63 |
# File 'lib/codeless_code/fable.rb', line 61 def translator @translator ||= dir_parts.last end |