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
11
# File 'lib/zendesk_apps_support/app_file.rb', line 7

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



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

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.



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

def absolute_path
  @absolute_path
end

#relative_pathObject (readonly) Also known as: to_s

Returns the value of attribute relative_path.



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

def relative_path
  @relative_path
end

Instance Method Details

#=~(regex) ⇒ Object



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

def =~(regex)
  relative_path =~ regex
end

#match(regex) ⇒ Object



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

def match(regex)
  self =~ regex
end

#readObject



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

def read
  File.read @file.path
end

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

Returns:

  • (Boolean)


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

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