Class: HaveAPI::OutputFormatters::BaseFormatter
- Inherits:
-
Object
- Object
- HaveAPI::OutputFormatters::BaseFormatter
- Defined in:
- lib/haveapi/output_formatters/base.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.types ⇒ Object
readonly
Returns the value of attribute types.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.types ⇒ Object (readonly)
Returns the value of attribute types.
4 5 6 |
# File 'lib/haveapi/output_formatters/base.rb', line 4 def types @types end |
Class Method Details
.handle(*args) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/haveapi/output_formatters/base.rb', line 6 def handle(*args) @types ||= [] @types += args HaveAPI::OutputFormatter.register(Kernel.const_get(to_s)) unless @registered @registered = true end |
.handle?(type) ⇒ Boolean
14 15 16 17 18 |
# File 'lib/haveapi/output_formatters/base.rb', line 14 def handle?(type) @types.detect do |t| File.fnmatch(type, t) end end |
Instance Method Details
#content_type ⇒ Object
21 22 23 |
# File 'lib/haveapi/output_formatters/base.rb', line 21 def content_type self.class.types.first end |
#format(response) ⇒ Object
25 |
# File 'lib/haveapi/output_formatters/base.rb', line 25 def format(response); end |