Class: DuperVisor::Content
- Inherits:
-
Object
- Object
- DuperVisor::Content
- Defined in:
- lib/dupervisor/content.rb
Overview
This class is responsible for taking the input and converting it into a Hash. It can also be initialized with the Hash, in which no conversion is performed.
The result
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#format ⇒ Object
Returns the value of attribute format.
-
#parse_result ⇒ Object
Returns the value of attribute parse_result.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(body: nil, format: nil) ⇒ Content
constructor
A new instance of Content.
Constructor Details
#initialize(body: nil, format: nil) ⇒ Content
Returns a new instance of Content.
14 15 16 17 18 |
# File 'lib/dupervisor/content.rb', line 14 def initialize(body: nil, format: nil) self.body = body self.format = format self.parse_result = {} end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
12 13 14 |
# File 'lib/dupervisor/content.rb', line 12 def body @body end |
#format ⇒ Object
Returns the value of attribute format.
12 13 14 |
# File 'lib/dupervisor/content.rb', line 12 def format @format end |
#parse_result ⇒ Object
Returns the value of attribute parse_result.
12 13 14 |
# File 'lib/dupervisor/content.rb', line 12 def parse_result @parse_result end |
Class Method Details
.to_format_from(hash, format) ⇒ Object
20 21 22 23 24 |
# File 'lib/dupervisor/content.rb', line 20 def self.to_format_from(hash, format) format_class = ::DuperVisor::Formats::Base.formats[format] raise ArgumentError.new("No format #{format} found") unless format_class Content.new(body: format_class.to.call(hash), format: format_class.format) end |