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.



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

def initialize(package, relative_path)
  @relative_path = relative_path
  @file = File.new(package.path_to(relative_path))
  @absolute_path = File.absolute_path @file.path
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



28
29
30
31
32
33
34
# File 'lib/zendesk_apps_support/app_file.rb', line 28

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

Instance Attribute Details

#absolute_pathObject (readonly)

Returns the value of attribute absolute_path.



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

def absolute_path
  @absolute_path
end

#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



18
19
20
# File 'lib/zendesk_apps_support/app_file.rb', line 18

def =~(regex)
  relative_path =~ regex
end

#match(regex) ⇒ Object



22
23
24
# File 'lib/zendesk_apps_support/app_file.rb', line 22

def match(regex)
  self =~ regex
end

#readObject



14
15
16
# File 'lib/zendesk_apps_support/app_file.rb', line 14

def read
  File.read @file.path
end

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

Returns:

  • (Boolean)


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

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