Class: Marti::MarticleBuilder
- Inherits:
-
Object
- Object
- Marti::MarticleBuilder
- Defined in:
- lib/marti/services/marticle_builder.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(path) ⇒ MarticleBuilder
constructor
A new instance of MarticleBuilder.
Constructor Details
#initialize(path) ⇒ MarticleBuilder
Returns a new instance of MarticleBuilder.
5 6 7 |
# File 'lib/marti/services/marticle_builder.rb', line 5 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/marti/services/marticle_builder.rb', line 3 def path @path end |
Instance Method Details
#build ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/marti/services/marticle_builder.rb', line 9 def build Marti.cache_store.fetch("marticle/"+path, expires_in: Marti.expires_in) do file = file_location(path) unless File.exists?(file) raise ::Marti::Errors::ArticleNotFoundError.new("#{path} not found") end article = Marti::MarticleParser.new(file).parse article.send(:instance_variable_set, "@path".to_sym, path) article end end |