Class: ExtractI18n::Adapters::Adapter
- Inherits:
-
Object
- Object
- ExtractI18n::Adapters::Adapter
- Defined in:
- lib/extract_i18n/adapters/adapter.rb
Direct Known Subclasses
ErbAdapter, JsAdapter, RubyAdapter, SlimAdapter, SlimAdapterWip, VueAdapter
Instance Attribute Summary collapse
-
#file_key ⇒ Object
readonly
Returns the value of attribute file_key.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#on_ask ⇒ Object
readonly
Returns the value of attribute on_ask.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file_key:, on_ask:, options: {}) ⇒ Adapter
constructor
A new instance of Adapter.
- #run(content) ⇒ Object
Constructor Details
#initialize(file_key:, on_ask:, options: {}) ⇒ Adapter
Returns a new instance of Adapter.
22 23 24 25 26 |
# File 'lib/extract_i18n/adapters/adapter.rb', line 22 def initialize(file_key:, on_ask:, options: {}) @on_ask = on_ask @file_key = file_key @options = end |
Instance Attribute Details
#file_key ⇒ Object (readonly)
Returns the value of attribute file_key.
20 21 22 |
# File 'lib/extract_i18n/adapters/adapter.rb', line 20 def file_key @file_key end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
20 21 22 |
# File 'lib/extract_i18n/adapters/adapter.rb', line 20 def file_path @file_path end |
#on_ask ⇒ Object (readonly)
Returns the value of attribute on_ask.
20 21 22 |
# File 'lib/extract_i18n/adapters/adapter.rb', line 20 def on_ask @on_ask end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
20 21 22 |
# File 'lib/extract_i18n/adapters/adapter.rb', line 20 def @options end |
Class Method Details
.for(file_path) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/extract_i18n/adapters/adapter.rb', line 5 def self.for(file_path) case file_path when /\.rb$/ then RubyAdapter when /\.erb$/ then ErbAdapter when /\.slim$/ then SlimAdapter when /\.ts$/, /\.js$/, /\.mjs/, /\.jsx$/ then JsAdapter when /\.vue$/ if File.read(file_path)[/lang=.pug./] VuePugAdapter else VueAdapter end end end |
.supports_relative_keys? ⇒ Boolean
32 33 34 |
# File 'lib/extract_i18n/adapters/adapter.rb', line 32 def self.supports_relative_keys? false end |
Instance Method Details
#run(content) ⇒ Object
28 29 30 |
# File 'lib/extract_i18n/adapters/adapter.rb', line 28 def run(content) raise NotImplementedError end |