Class: ZendeskAppsSupport::AppFile

Inherits:
Object
  • Object
show all
Defined in:
lib/zendesk_apps_support/app_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package, relative_path) ⇒ AppFile

Returns a new instance of AppFile.



7
8
9
10
# File 'lib/zendesk_apps_support/app_file.rb', line 7

def initialize(package, relative_path)
  @relative_path = relative_path
  @file = File.new(package.root.join(relative_path))
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/zendesk_apps_support/app_file.rb', line 22

def method_missing(sym, *args, &block)
  if @file.respond_to?(sym)
    @file.call(sym, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#relative_pathObject (readonly) Also known as: to_s

Returns the value of attribute relative_path.



5
6
7
# File 'lib/zendesk_apps_support/app_file.rb', line 5

def relative_path
  @relative_path
end

Instance Method Details

#=~(regex) ⇒ Object



16
17
18
# File 'lib/zendesk_apps_support/app_file.rb', line 16

def =~(regex)
  @relative_path =~ regex
end

#readObject



12
13
14
# File 'lib/zendesk_apps_support/app_file.rb', line 12

def read
  File.read @file.path
end

#respond_to?(sym, include_private = false) ⇒ Boolean

Unless Ruby 1.9

Returns:

  • (Boolean)


31
32
33
# File 'lib/zendesk_apps_support/app_file.rb', line 31

def respond_to?(sym, include_private = false)
  @file.respond_to?(sym, include_private) || super
end

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

If Ruby 1.9

Returns:

  • (Boolean)


36
37
38
# File 'lib/zendesk_apps_support/app_file.rb', line 36

def respond_to_missing?(sym, include_private = false)
  @file.respond_to_missing?(sym, include_private) || super
end