Class: DependencySpy::Dependency

Inherits:
Struct
  • Object
show all
Defined in:
lib/dependency_spy/dtos/dependency.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



52
53
54
# File 'lib/dependency_spy/dtos/dependency.rb', line 52

def name
  @name
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



52
53
54
# File 'lib/dependency_spy/dtos/dependency.rb', line 52

def type
  @type
end

#versionObject

Returns the value of attribute version

Returns:

  • (Object)

    the current value of version



52
53
54
# File 'lib/dependency_spy/dtos/dependency.rb', line 52

def version
  @version
end

#vulnerabilitiesObject

Returns the value of attribute vulnerabilities

Returns:

  • (Object)

    the current value of vulnerabilities



52
53
54
# File 'lib/dependency_spy/dtos/dependency.rb', line 52

def vulnerabilities
  @vulnerabilities
end

Instance Method Details

#to_json(*args) ⇒ Object



75
76
77
# File 'lib/dependency_spy/dtos/dependency.rb', line 75

def to_json(*args)
  to_map.to_json(*args)
end

#to_mapObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/dependency_spy/dtos/dependency.rb', line 59

def to_map
  map = {}
  members.each do |m|
    if !self[m] ||
       (self[m].is_a?(String) && self[m].empty?) ||
       (self[m].is_a?(Array) && self[m].none?)
      next
    elsif self[m].is_a?(Struct)
      map[m.to_s] = self[m].to_map
    else
      map[m.to_s] = self[m]
    end
  end
  map
end

#to_yaml(*args) ⇒ Object



79
80
81
# File 'lib/dependency_spy/dtos/dependency.rb', line 79

def to_yaml(*args)
  to_map.to_yaml(*args)
end