Class: Emma::Report::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/emma/report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element) ⇒ Node

Returns a new instance of Node.



45
46
47
# File 'lib/emma/report.rb', line 45

def initialize(element)
  @element = element
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



43
44
45
# File 'lib/emma/report.rb', line 43

def parent
  @parent
end

Instance Method Details

#classesObject



61
62
63
# File 'lib/emma/report.rb', line 61

def classes
  nodes_from @element.xpath(".//class")
end

#coveragesObject



83
84
85
86
87
88
89
90
# File 'lib/emma/report.rb', line 83

def coverages
  @coverages ||= Coverages.new(
    coverage_value_for('class'),
    coverage_value_for('method'),
    coverage_value_for('block'),
    coverage_value_for('line')
  )
end

#inspectObject



49
50
51
# File 'lib/emma/report.rb', line 49

def inspect
  '#<%s:0x%x %s>' % [self.class, hash, "type=#{type.inspect} name=#{name.inspect}"]
end

#methodsObject



69
70
71
# File 'lib/emma/report.rb', line 69

def methods
  nodes_from @element.xpath(".//method")
end

#nameObject



73
74
75
76
77
78
79
80
81
# File 'lib/emma/report.rb', line 73

def name
  name = @element['name']
  parent = @element.parent
  if parent and not ['data', 'all'].include? parent.name
    name = [Node.new(parent).name, name].join ':'
  end

  name
end

#packagesObject



57
58
59
# File 'lib/emma/report.rb', line 57

def packages
  nodes_from @element.xpath(".//package")
end

#source_filesObject



65
66
67
# File 'lib/emma/report.rb', line 65

def source_files
  nodes_from @element.xpath(".//srcfile")
end

#typeObject



53
54
55
# File 'lib/emma/report.rb', line 53

def type
  @element.name.to_sym
end