Class: Steep::AST::Types::Masked
- Inherits:
-
Object
- Object
- Steep::AST::Types::Masked
- Defined in:
- lib/steep/ast/types.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#mask ⇒ Object
readonly
Returns the value of attribute mask.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #each_type(&block) ⇒ Object
- #free_variables(set = Set.new) ⇒ Object
- #hash ⇒ Object
-
#initialize(type:, mask:, location:) ⇒ Masked
constructor
A new instance of Masked.
- #sub(s) ⇒ Object
- #to_json(*a) ⇒ Object
- #to_s(level = 0) ⇒ Object
Constructor Details
#initialize(type:, mask:, location:) ⇒ Masked
Returns a new instance of Masked.
9 10 11 12 13 |
# File 'lib/steep/ast/types.rb', line 9 def initialize(type:, mask:, location:) @type = type @mask = mask @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
5 6 7 |
# File 'lib/steep/ast/types.rb', line 5 def location @location end |
#mask ⇒ Object (readonly)
Returns the value of attribute mask.
7 8 9 |
# File 'lib/steep/ast/types.rb', line 7 def mask @mask end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/steep/ast/types.rb', line 6 def type @type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
15 16 17 18 19 |
# File 'lib/steep/ast/types.rb', line 15 def ==(other) other.is_a?(Masked) && other.type == type && other.mask == mask end |
#each_type(&block) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/steep/ast/types.rb', line 43 def each_type(&block) if block_given? yield type yield mask else enum_for :each_type end end |
#free_variables(set = Set.new) ⇒ Object
38 39 40 41 |
# File 'lib/steep/ast/types.rb', line 38 def free_variables(set = Set.new) type.free_variables(set) mask.free_variables(set) end |
#hash ⇒ Object
23 24 25 |
# File 'lib/steep/ast/types.rb', line 23 def hash self.class.hash ^ type.hash ^ mask.hash end |
#sub(s) ⇒ Object
52 53 54 55 56 |
# File 'lib/steep/ast/types.rb', line 52 def sub(s) self.class.new(type: type.sub(s), mask: mask.sub(s), location: location) end |
#to_json(*a) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/steep/ast/types.rb', line 27 def to_json(*a) { class: :masked, type: type, mask: mask, location: location }.to_json(*a) end |
#to_s(level = 0) ⇒ Object
34 35 36 |
# File 'lib/steep/ast/types.rb', line 34 def to_s(level = 0) "masked(#{type}|#{mask})" end |