Class: Cel::Message
- Inherits:
-
Object
- Object
- Cel::Message
- Defined in:
- lib/cel/ast/elements/message.rb
Constant Summary collapse
- EMPTY_STRUCT =
{}.freeze
Instance Attribute Summary collapse
-
#depth ⇒ Object
readonly
Returns the value of attribute depth.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#package ⇒ Object
readonly
Returns the value of attribute package.
-
#struct ⇒ Object
readonly
Returns the value of attribute struct.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(name, struct, package: nil, depth: 1) ⇒ Message
constructor
A new instance of Message.
- #message_type ⇒ Object
- #proto_type ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(name, struct, package: nil, depth: 1) ⇒ Message
Returns a new instance of Message.
9 10 11 12 13 14 |
# File 'lib/cel/ast/elements/message.rb', line 9 def initialize(name, struct, package: nil, depth: 1) @struct = struct ? struct.transform_keys(&:to_sym) : EMPTY_STRUCT @name = name @package = package @depth = depth end |
Instance Attribute Details
#depth ⇒ Object (readonly)
Returns the value of attribute depth.
7 8 9 |
# File 'lib/cel/ast/elements/message.rb', line 7 def depth @depth end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/cel/ast/elements/message.rb', line 7 def name @name end |
#package ⇒ Object (readonly)
Returns the value of attribute package.
7 8 9 |
# File 'lib/cel/ast/elements/message.rb', line 7 def package @package end |
#struct ⇒ Object (readonly)
Returns the value of attribute struct.
7 8 9 |
# File 'lib/cel/ast/elements/message.rb', line 7 def struct @struct end |
Instance Method Details
#==(other) ⇒ Object
32 33 34 |
# File 'lib/cel/ast/elements/message.rb', line 32 def ==(other) other.is_a?(Cel::Message) && other.name == @name && other.struct == @struct end |
#message_type ⇒ Object
24 25 26 |
# File 'lib/cel/ast/elements/message.rb', line 24 def ||= proto_type || container end |
#proto_type ⇒ Object
28 29 30 |
# File 'lib/cel/ast/elements/message.rb', line 28 def proto_type @proto_type ||= Protobuf.convert_to_proto_type(@name.to_s, @package) end |
#to_s ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/cel/ast/elements/message.rb', line 36 def to_s if proto_type proto_type.descriptor.name else .to_s end end |
#type ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/cel/ast/elements/message.rb', line 16 def type @type ||= if proto_type Protobuf.convert_to_cel_type(proto_type, @package) || proto_type else Protobuf.try_convert_from_wrapper_type(@name.to_s) end end |