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.



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

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



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

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.



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

def absolute_path
  @absolute_path
end

#relative_pathObject (readonly) Also known as: to_s

Returns the value of attribute relative_path.



3
4
5
# File 'lib/zendesk_apps_support/app_file.rb', line 3

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

#match(regex) ⇒ Object



20
21
22
# File 'lib/zendesk_apps_support/app_file.rb', line 20

def match(regex)
  self =~ 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_missing?(sym, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/zendesk_apps_support/app_file.rb', line 34

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