class EasyRspec::FileContents
Attributes
class_methods[RW]
instance_methods[RW]
Public Class Methods
new(file_path)
click to toggle source
# File lib/easy_rspec/file_contents.rb, line 6 def initialize(file_path) self.instance_methods = [] self.class_methods = [] find_contents(file_path) end
Private Instance Methods
class_method_name(line)
click to toggle source
# File lib/easy_rspec/file_contents.rb, line 29 def class_method_name(line) line.gsub('def self.','').gsub('\n', '').strip end
find_contents(file_path)
click to toggle source
# File lib/easy_rspec/file_contents.rb, line 14 def find_contents(file_path) File.foreach(file_path) do |line| if line_contains_class_method?(line) class_methods << class_method_name(line) end if line_contains_instance_method?(line) instance_methods << instance_method_name(line) end end end
instance_method_name(line)
click to toggle source
# File lib/easy_rspec/file_contents.rb, line 37 def instance_method_name(line) line.gsub('def ','').gsub('\n', '').strip end
line_contains_class_method?(line)
click to toggle source
# File lib/easy_rspec/file_contents.rb, line 25 def line_contains_class_method?(line) line.include?('def self.') end
line_contains_instance_method?(line)
click to toggle source
# File lib/easy_rspec/file_contents.rb, line 33 def line_contains_instance_method?(line) !line_contains_class_method?(line) && line.include?('def ') end