Class: Motoko::Resolvers::BaseResolver
- Inherits:
-
Object
- Object
- Motoko::Resolvers::BaseResolver
- Includes:
- Utils::SnakeToCamel
- Defined in:
- lib/motoko/resolvers/base_resolver.rb
Direct Known Subclasses
Cpu, Fact, Identity, Os, RebootRequired
Instance Attribute Summary collapse
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
- #human_name ⇒ Object
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #align ⇒ Object
-
#initialize(name, options) ⇒ BaseResolver
constructor
A new instance of BaseResolver.
- #resolve_for(_node) ⇒ Object
- #value(node) ⇒ Object
Methods included from Utils::SnakeToCamel
Constructor Details
#initialize(name, options) ⇒ BaseResolver
Returns a new instance of BaseResolver.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/motoko/resolvers/base_resolver.rb', line 14 def initialize(name, ) ||= {} @name = name @human_name = .delete('human_name') if .key?('human_name') formatter = .delete('formatter') || 'base_formatter' @align = .delete('align') @formatter = Object.const_get("Motoko::Formatters::#{snake_to_camel_case(formatter)}").new() puts "unused keys for column #{name}: #{options.keys.join(', ')}" if .keys.any? end |
Instance Attribute Details
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
10 11 12 |
# File 'lib/motoko/resolvers/base_resolver.rb', line 10 def formatter @formatter end |
#human_name ⇒ Object
31 32 33 |
# File 'lib/motoko/resolvers/base_resolver.rb', line 31 def human_name @human_name ||= name.tr('_', ' ').gsub('.', ' > ').split.map(&:capitalize).join(' ') end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/motoko/resolvers/base_resolver.rb', line 8 def name @name end |
Instance Method Details
#align ⇒ Object
27 28 29 |
# File 'lib/motoko/resolvers/base_resolver.rb', line 27 def align @align&.to_sym end |
#resolve_for(_node) ⇒ Object
35 36 37 |
# File 'lib/motoko/resolvers/base_resolver.rb', line 35 def resolve_for(_node) raise 'Not implemented' end |
#value(node) ⇒ Object
39 40 41 |
# File 'lib/motoko/resolvers/base_resolver.rb', line 39 def value(node) formatter.format(resolve_for(node)) end |