Class: Ast::Crispr::StructureProfile

Inherits:
Object
  • Object
show all
Includes:
ProfileReportCompatibility
Defined in:
lib/ast/crispr.rb,
lib/ast/crispr.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(owner_scope:, owner_selector:, supported_comment_regions: [], metadata: {}, **options) ⇒ StructureProfile

Returns a new instance of StructureProfile.



457
458
459
460
461
462
# File 'lib/ast/crispr.rb', line 457

def initialize(owner_scope:, owner_selector:, supported_comment_regions: [], metadata: {}, **options)
  @owner_scope = owner_scope&.to_sym
  @owner_selector = owner_selector&.to_sym
  @supported_comment_regions = Array(supported_comment_regions).map(&:to_sym).freeze
  @metadata = .merge(options).freeze
end

Instance Attribute Details

#metadataObject (readonly)

Returns the value of attribute metadata.



455
456
457
# File 'lib/ast/crispr.rb', line 455

def 
  @metadata
end

#owner_scopeObject (readonly)

Returns the value of attribute owner_scope.



455
456
457
# File 'lib/ast/crispr.rb', line 455

def owner_scope
  @owner_scope
end

#owner_selectorObject (readonly)

Returns the value of attribute owner_selector.



455
456
457
# File 'lib/ast/crispr.rb', line 455

def owner_selector
  @owner_selector
end

#supported_comment_regionsObject (readonly)

Returns the value of attribute supported_comment_regions.



455
456
457
# File 'lib/ast/crispr.rb', line 455

def supported_comment_regions
  @supported_comment_regions
end

Instance Method Details

#known_owner_selector?Boolean

Returns:

  • (Boolean)


472
473
474
# File 'lib/ast/crispr.rb', line 472

def known_owner_selector?
  Ast::Merge::Ruleset::ProfileVocabulary.known_owner_selector?(owner_selector)
end

#owner_selector_familyObject



468
469
470
# File 'lib/ast/crispr.rb', line 468

def owner_selector_family
  &.fetch(:family, nil)
end

#owner_selector_metadataObject



464
465
466
# File 'lib/ast/crispr.rb', line 464

def 
  Ast::Merge::Ruleset::ProfileVocabulary.(owner_selector)
end

#reportObject



1680
1681
1682
# File 'lib/ast/crispr.rb', line 1680

def report
  stringified_report(to_h)
end

#supports_comment_region?(region) ⇒ Boolean

Returns:

  • (Boolean)


476
477
478
# File 'lib/ast/crispr.rb', line 476

def supports_comment_region?(region)
  supported_comment_regions.include?(region.to_sym)
end

#to_hObject



480
481
482
483
484
485
486
487
488
489
# File 'lib/ast/crispr.rb', line 480

def to_h
  {
    owner_scope: owner_scope,
    owner_selector: owner_selector,
    owner_selector_family: owner_selector_family,
    known_owner_selector: known_owner_selector?,
    supported_comment_regions: supported_comment_regions,
    metadata: 
  }
end