Class: Gapic::Presenters::EnumValuePresenter
- Inherits:
-
Object
- Object
- Gapic::Presenters::EnumValuePresenter
- Defined in:
- lib/gapic/presenters/enum_value_presenter.rb
Overview
A presenter for proto enum values.
Instance Method Summary collapse
- #doc_description ⇒ Object
-
#doc_line ⇒ String
collision.
-
#initialize(value) ⇒ EnumValuePresenter
constructor
A new instance of EnumValuePresenter.
-
#keyword_collision? ⇒ Boolean
Whether the enum name collides with a Ruby keyword.
-
#name ⇒ String
The enum value name without keyword collision.
- #number ⇒ Object
Constructor Details
#initialize(value) ⇒ EnumValuePresenter
Returns a new instance of EnumValuePresenter.
25 26 27 |
# File 'lib/gapic/presenters/enum_value_presenter.rb', line 25 def initialize value @value = value end |
Instance Method Details
#doc_description ⇒ Object
45 46 47 |
# File 'lib/gapic/presenters/enum_value_presenter.rb', line 45 def doc_description @value.docs_leading_comments end |
#doc_line ⇒ String
collision.
41 42 43 |
# File 'lib/gapic/presenters/enum_value_presenter.rb', line 41 def doc_line keyword_collision? ? "const_set :#{@value.name}, #{@value.number}" : "#{@value.name} = #{@value.number}" end |
#keyword_collision? ⇒ Boolean
Returns Whether the enum name collides with a Ruby keyword.
35 36 37 |
# File 'lib/gapic/presenters/enum_value_presenter.rb', line 35 def keyword_collision? Gapic::RubyInfo.keywords.include? @value.name end |
#name ⇒ String
Returns The enum value name without keyword collision.
30 31 32 |
# File 'lib/gapic/presenters/enum_value_presenter.rb', line 30 def name keyword_collision? ? "#{@value.parent.name}::#{@value.name}" : @value.name end |
#number ⇒ Object
49 50 51 |
# File 'lib/gapic/presenters/enum_value_presenter.rb', line 49 def number @value.number end |