Class: Paf::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/paf/formatter.rb

Overview

Processing to format a PAF entry

Direct Known Subclasses

ArrayFormatter, HashFormatter, StringFormatter

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



15
16
17
18
19
# File 'lib/paf/formatter.rb', line 15

def method_missing(method, *args)
  return @paf.send(method, *args) if @paf.respond_to?(method)
  return @paf.class.send(method, *args) if @paf.class.respond_to?(method)
  super
end

Class Method Details

.format(paf) ⇒ Object



6
7
8
# File 'lib/paf/formatter.rb', line 6

def self.format(paf)
  new.format(paf)
end

Instance Method Details

#format(paf) ⇒ Object



10
11
12
13
# File 'lib/paf/formatter.rb', line 10

def format(paf)
  @paf = paf.clone
  @paf.extend Lineable
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/paf/formatter.rb', line 21

def respond_to_missing?(method_name, include_private = false)
  @paf.respond_to?(method) || @paf.class.respond_to?(method) || super
end