Class: WhyClasses::Correctors::DataBucketCorrector::Analysis
- Inherits:
-
Data
- Object
- Data
- WhyClasses::Correctors::DataBucketCorrector::Analysis
- Defined in:
- lib/why_classes/correctors/data_bucket_corrector.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#keyword ⇒ Object
readonly
Returns the value of attribute keyword.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
Instance Method Summary collapse
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields
15 16 17 |
# File 'lib/why_classes/correctors/data_bucket_corrector.rb', line 15 def fields @fields end |
#keyword ⇒ Object (readonly)
Returns the value of attribute keyword
15 16 17 |
# File 'lib/why_classes/correctors/data_bucket_corrector.rb', line 15 def keyword @keyword end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind
15 16 17 |
# File 'lib/why_classes/correctors/data_bucket_corrector.rb', line 15 def kind @kind end |
Instance Method Details
#replacement(name) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/why_classes/correctors/data_bucket_corrector.rb', line 16 def replacement(name) list = fields.map { |f| ":#{f}" }.join(", ") case kind when :data "#{name} = Data.define(#{list})" when :struct keyword ? "#{name} = Struct.new(#{list}, keyword_init: true)" : "#{name} = Struct.new(#{list})" end end |