Class: CommentExtractor::CodeObjects

Inherits:
Array
  • Object
show all
Defined in:
lib/comment_extractor/code_objects.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file: nil) ⇒ CodeObjects

Returns a new instance of CodeObjects.



7
8
9
10
# File 'lib/comment_extractor/code_objects.rb', line 7

def initialize(file: nil)
  @file = file
  super([])
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



5
6
7
# File 'lib/comment_extractor/code_objects.rb', line 5

def file
  @file
end

Instance Method Details

#<<(code_object) ⇒ Object



12
13
14
# File 'lib/comment_extractor/code_objects.rb', line 12

def <<(code_object)
  super(initialize_code_object(code_object))
end

#concat(*code_object_arrays) ⇒ Object



21
22
23
24
# File 'lib/comment_extractor/code_objects.rb', line 21

def concat(*code_object_arrays)
  arguments = code_object_arrays.flatten.map { |v| initialize_code_object(v) }
  super(arguments)
end

#inspectObject Also known as: to_s



26
27
28
29
30
31
# File 'lib/comment_extractor/code_objects.rb', line 26

def inspect
  attributes = instance_variables.map { |v| "@#{v}=#{instance_variable_get(v)}" }
  attributes = attributes.empty? ? '' : " #{attributes.join(', ')}"
  object_id = '0x%x' % (self.object_id << 1)
  "#<#{self.class}:#{object_id}#{attributes}>"
end

#push(*code_object_array) ⇒ Object



16
17
18
19
# File 'lib/comment_extractor/code_objects.rb', line 16

def push(*code_object_array)
  arguments = code_object_array.map { |v| initialize_code_object(v) }
  super(*arguments)
end