Class: Transpec::Record
- Inherits:
-
Object
show all
- Defined in:
- lib/transpec/record.rb
Constant Summary
collapse
- OVERRIDE_FORBIDDEN_METHODS =
[
:original_syntax,
:original_syntax_type,
:converted_syntax,
:converted_syntax_type
]
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(original_syntax, converted_syntax, annotation = nil) ⇒ Record
Returns a new instance of Record.
16
17
18
19
20
|
# File 'lib/transpec/record.rb', line 16
def initialize(original_syntax, converted_syntax, annotation = nil)
@original_syntax_type = original_syntax.to_sym
@converted_syntax_type = converted_syntax.to_sym
@annotation = annotation
end
|
Instance Attribute Details
#annotation ⇒ Object
Returns the value of attribute annotation.
14
15
16
|
# File 'lib/transpec/record.rb', line 14
def annotation
@annotation
end
|
#converted_syntax_type ⇒ Object
Returns the value of attribute converted_syntax_type.
14
15
16
|
# File 'lib/transpec/record.rb', line 14
def converted_syntax_type
@converted_syntax_type
end
|
#original_syntax_type ⇒ Object
Returns the value of attribute original_syntax_type.
14
15
16
|
# File 'lib/transpec/record.rb', line 14
def original_syntax_type
@original_syntax_type
end
|
Class Method Details
.method_added(method_name) ⇒ Object
64
65
66
67
|
# File 'lib/transpec/record.rb', line 64
def self.method_added(method_name)
return unless OVERRIDE_FORBIDDEN_METHODS.include?(method_name)
fail "Do not override Record##{method_name}."
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
38
39
40
41
42
|
# File 'lib/transpec/record.rb', line 38
def ==(other)
self.class == other.class &&
original_syntax_type == other.original_syntax_type &&
converted_syntax_type == other.converted_syntax_type
end
|
#converted_syntax ⇒ Object
26
27
28
|
# File 'lib/transpec/record.rb', line 26
def converted_syntax
converted_syntax_type.to_s
end
|
#hash ⇒ Object
46
47
48
|
# File 'lib/transpec/record.rb', line 46
def hash
original_syntax_type.hash ^ converted_syntax_type.hash
end
|
#original_syntax ⇒ Object
22
23
24
|
# File 'lib/transpec/record.rb', line 22
def original_syntax
original_syntax_type.to_s
end
|
#to_s ⇒ Object
50
51
52
|
# File 'lib/transpec/record.rb', line 50
def to_s
"`#{original_syntax_type}` -> `#{converted_syntax_type}`"
end
|