Class: Scripref::Formatter
- Inherits:
-
Object
- Object
- Scripref::Formatter
- Defined in:
- lib/scripref/formatter.rb
Instance Attribute Summary collapse
-
#bookformat ⇒ Object
Returns the value of attribute bookformat.
-
#cv_separator ⇒ Object
Returns the value of attribute cv_separator.
-
#hyphen_separator ⇒ Object
Returns the value of attribute hyphen_separator.
-
#pass_separator ⇒ Object
Returns the value of attribute pass_separator.
Instance Method Summary collapse
-
#format(*reference) ⇒ Object
(also: #<<)
Formats a reference (array of passages and maybe separators).
-
#format_addon(a) ⇒ Object
Formats a verse addon.
-
#format_book(osis_book_id) ⇒ Object
Formats a book.
-
#format_chapter(num) ⇒ Object
Formats a chapter.
-
#format_postfix(p) ⇒ Object
Formats a verse postfix.
-
#format_verse(num) ⇒ Object
Formats a verse.
-
#initialize(*mods, bookformat: :name) ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize(*mods, bookformat: :name) ⇒ Formatter
Returns a new instance of Formatter.
12 13 14 15 16 |
# File 'lib/scripref/formatter.rb', line 12 def initialize *mods, bookformat: :name @mods = mods mods.each {|m| extend m} @bookformat = bookformat end |
Instance Attribute Details
#bookformat ⇒ Object
Returns the value of attribute bookformat.
8 9 10 |
# File 'lib/scripref/formatter.rb', line 8 def bookformat @bookformat end |
#cv_separator ⇒ Object
Returns the value of attribute cv_separator.
8 9 10 |
# File 'lib/scripref/formatter.rb', line 8 def cv_separator @cv_separator end |
#hyphen_separator ⇒ Object
Returns the value of attribute hyphen_separator.
8 9 10 |
# File 'lib/scripref/formatter.rb', line 8 def hyphen_separator @hyphen_separator end |
#pass_separator ⇒ Object
Returns the value of attribute pass_separator.
8 9 10 |
# File 'lib/scripref/formatter.rb', line 8 def pass_separator @pass_separator end |
Instance Method Details
#format(*reference) ⇒ Object Also known as: <<
Formats a reference (array of passages and maybe separators)
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/scripref/formatter.rb', line 19 def format *reference @last_b = @last_c = @last_v = :undefined @result = [] reference.flatten.each do |entry| next if entry.kind_of? Sep @pass = entry process_passage end @result.join end |
#format_addon(a) ⇒ Object
Formats a verse addon
49 50 51 |
# File 'lib/scripref/formatter.rb', line 49 def format_addon a a.to_s end |
#format_book(osis_book_id) ⇒ Object
Formats a book
32 33 34 |
# File 'lib/scripref/formatter.rb', line 32 def format_book osis_book_id osis_book_id_to_book_name[osis_book_id].send @bookformat end |
#format_chapter(num) ⇒ Object
Formats a chapter
38 39 40 |
# File 'lib/scripref/formatter.rb', line 38 def format_chapter num num.to_s end |
#format_postfix(p) ⇒ Object
Formats a verse postfix
54 55 56 |
# File 'lib/scripref/formatter.rb', line 54 def format_postfix p p.to_s end |
#format_verse(num) ⇒ Object
Formats a verse
44 45 46 |
# File 'lib/scripref/formatter.rb', line 44 def format_verse num num.to_s end |