Class: ReVIEW::Catalog
Instance Method Summary collapse
- #appendix ⇒ Object
- #chaps ⇒ Object
-
#initialize(file) ⇒ Catalog
constructor
A new instance of Catalog.
- #parts ⇒ Object
- #parts_with_chaps ⇒ Object
- #postdef ⇒ Object
- #predef ⇒ Object
Constructor Details
#initialize(file) ⇒ Catalog
Returns a new instance of Catalog.
5 6 7 8 |
# File 'lib/review/catalog.rb', line 5 def initialize(file) @yaml = YAML.load(file.read) @yaml ||= {} end |
Instance Method Details
#appendix ⇒ Object
42 43 44 45 |
# File 'lib/review/catalog.rb', line 42 def appendix return "" unless @yaml["APPENDIX"] @yaml["APPENDIX"].join("\n") end |
#chaps ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/review/catalog.rb', line 15 def chaps return "" unless @yaml["CHAPS"] @yaml["CHAPS"].map {|entry| if entry.is_a? String entry elsif entry.is_a? Hash entry.values # chaps in a part end }.flatten.join("\n") end |
#parts ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/review/catalog.rb', line 27 def parts return "" unless @yaml["CHAPS"] @yaml["CHAPS"].map {|entry| if entry.is_a? Hash entry.keys end }.flatten.reject{|entry| entry.nil?}.join("\n") end |
#parts_with_chaps ⇒ Object
37 38 39 40 |
# File 'lib/review/catalog.rb', line 37 def parts_with_chaps return "" unless @yaml["CHAPS"] @yaml["CHAPS"].flatten.reject{|entry| entry.nil?} end |
#postdef ⇒ Object
47 48 49 50 |
# File 'lib/review/catalog.rb', line 47 def postdef return "" unless @yaml["POSTDEF"] @yaml["POSTDEF"].join("\n") end |
#predef ⇒ Object
10 11 12 13 |
# File 'lib/review/catalog.rb', line 10 def predef return "" unless @yaml["PREDEF"] @yaml["PREDEF"].join("\n") end |