Class: DiverDown::Web::Metadata::SourceMetadata
- Inherits:
-
Object
- Object
- DiverDown::Web::Metadata::SourceMetadata
- Defined in:
- lib/diver_down/web/metadata/source_metadata.rb
Constant Summary collapse
- DEPENDENCY_TYPES =
%w[valid invalid todo ignore].freeze
Instance Attribute Summary collapse
-
#dependency_types ⇒ Object
Returns the value of attribute dependency_types.
-
#memo ⇒ Object
Returns the value of attribute memo.
-
#module ⇒ Object
Returns the value of attribute module.
Instance Method Summary collapse
- #dependency_type(to_source) ⇒ String?
-
#initialize(memo: BLANK_MEMO, modulee: nil, dependency_types: {}) ⇒ SourceMetadata
constructor
NOTE: ‘module` is a reserved keyword in Ruby.
- #module? ⇒ Boolean
- #to_h ⇒ Hash
- #update_dependency_type(to_source, dependency_type) ⇒ void
Constructor Details
#initialize(memo: BLANK_MEMO, modulee: nil, dependency_types: {}) ⇒ SourceMetadata
NOTE: ‘module` is a reserved keyword in Ruby
18 19 20 21 22 |
# File 'lib/diver_down/web/metadata/source_metadata.rb', line 18 def initialize(memo: BLANK_MEMO, modulee: nil, dependency_types: {}) @memo = memo @module = modulee @dependency_types = dependency_types end |
Instance Attribute Details
#dependency_types ⇒ Object
Returns the value of attribute dependency_types.
14 15 16 |
# File 'lib/diver_down/web/metadata/source_metadata.rb', line 14 def dependency_types @dependency_types end |
#memo ⇒ Object
Returns the value of attribute memo.
14 15 16 |
# File 'lib/diver_down/web/metadata/source_metadata.rb', line 14 def memo @memo end |
#module ⇒ Object
Returns the value of attribute module.
14 15 16 |
# File 'lib/diver_down/web/metadata/source_metadata.rb', line 14 def module @module end |
Instance Method Details
#dependency_type(to_source) ⇒ String?
42 43 44 |
# File 'lib/diver_down/web/metadata/source_metadata.rb', line 42 def dependency_type(to_source) @dependency_types[to_source] end |
#module? ⇒ Boolean
70 71 72 |
# File 'lib/diver_down/web/metadata/source_metadata.rb', line 70 def module? !@module.nil? end |
#to_h ⇒ Hash
75 76 77 78 79 80 81 82 83 |
# File 'lib/diver_down/web/metadata/source_metadata.rb', line 75 def to_h hash = {} hash[:memo] = memo unless memo == BLANK_MEMO hash[:module] = @module unless @module.nil? hash[:dependency_types] = @dependency_types unless @dependency_types.empty? hash end |
#update_dependency_type(to_source, dependency_type) ⇒ void
This method returns an undefined value.
59 60 61 62 63 64 65 66 67 |
# File 'lib/diver_down/web/metadata/source_metadata.rb', line 59 def update_dependency_type(to_source, dependency_type) if dependency_type.to_s.empty? @dependency_types.delete(to_source) else raise ArgumentError, "invalid dependency_type: #{dependency_type}" unless DEPENDENCY_TYPES.include?(dependency_type) @dependency_types[to_source] = dependency_type end end |