Class: Tableview::Helper::Format

Inherits:
Object
  • Object
show all
Defined in:
lib/tableview/helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(p) ⇒ Format

Returns a new instance of Format.



4
5
6
# File 'lib/tableview/helper.rb', line 4

def initialize(p)
  @params = p
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &blk) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/tableview/helper.rb', line 12

def method_missing(name, *args, &blk)
  puts name.inspect
  if m = name.to_s.match(/^(.+)\?$/)
    puts "matched"
    #puts m.inspect, name.inspect
    @params[:format] == m.captures.first
  else
    puts "did not match"
    super
  end
end

Instance Method Details

#html?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/tableview/helper.rb', line 8

def html?
  @params[:format] == :html || @params[:format].blank?
end