Class: Marshalsea::Marshal::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/marshalsea/marshal/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root, major:, minor:, role_anomalies: []) ⇒ Result

Returns a new instance of Result.



118
119
120
121
122
123
# File 'lib/marshalsea/marshal/node.rb', line 118

def initialize(root, major:, minor:, role_anomalies: [])
  @root = root
  @major = major
  @minor = minor
  @role_anomalies = role_anomalies
end

Instance Attribute Details

#majorObject (readonly)

Returns the value of attribute major.



116
117
118
# File 'lib/marshalsea/marshal/node.rb', line 116

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



116
117
118
# File 'lib/marshalsea/marshal/node.rb', line 116

def minor
  @minor
end

#role_anomaliesObject (readonly)

Returns the value of attribute role_anomalies.



116
117
118
# File 'lib/marshalsea/marshal/node.rb', line 116

def role_anomalies
  @role_anomalies
end

#rootObject (readonly)

Returns the value of attribute root.



116
117
118
# File 'lib/marshalsea/marshal/node.rb', line 116

def root
  @root
end

Instance Method Details

#canonical_roles?Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/marshalsea/marshal/node.rb', line 129

def canonical_roles?
  role_anomalies.empty?
end

#canonical_version?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/marshalsea/marshal/node.rb', line 125

def canonical_version?
  major == Constants::MAJOR_VERSION && minor == Constants::MINOR_VERSION
end

#class_namesObject



137
138
139
# File 'lib/marshalsea/marshal/node.rb', line 137

def class_names
  nodes.filter_map(&:class_name).uniq
end

#dispatching_hash_keysObject



156
157
158
# File 'lib/marshalsea/marshal/node.rb', line 156

def dispatching_hash_keys
  hash_keys.select(&:dispatches_key_methods?)
end

#eql_dispatching_keysObject



164
165
166
# File 'lib/marshalsea/marshal/node.rb', line 164

def eql_dispatching_keys
  hash_keys.filter_map(&:eql_dispatcher)
end

#gated_sinksObject



145
146
147
# File 'lib/marshalsea/marshal/node.rb', line 145

def gated_sinks
  sinks.select(&:gated?)
end

#hash_dispatching_keysObject



160
161
162
# File 'lib/marshalsea/marshal/node.rb', line 160

def hash_dispatching_keys
  hash_keys.filter_map(&:hash_dispatcher)
end

#hash_keysObject



149
150
151
152
153
154
# File 'lib/marshalsea/marshal/node.rb', line 149

def hash_keys
  nodes.select { |node| node.type == :hash }
       .flat_map(&:children)
       .select { |child| child.type == :pair }
       .filter_map { |pair| pair.children.first }
end

#nodesObject



133
134
135
# File 'lib/marshalsea/marshal/node.rb', line 133

def nodes
  root.each
end

#range_endpoint_dispatchersObject



168
169
170
171
# File 'lib/marshalsea/marshal/node.rb', line 168

def range_endpoint_dispatchers
  nodes.select { |node| node.effective_class_name == Constants::RANGE_CLASS_NAME }
       .flat_map(&:range_endpoints)
end

#sinksObject



141
142
143
# File 'lib/marshalsea/marshal/node.rb', line 141

def sinks
  nodes.select(&:sink?)
end