Class: AwesomeTranslations::ErbInspector::TranslationInspector
- Inherits:
-
Object
- Object
- AwesomeTranslations::ErbInspector::TranslationInspector
- Defined in:
- lib/awesome_translations/erb_inspector/translation_inspector.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#full_key ⇒ Object
readonly
Returns the value of attribute full_key.
-
#full_path ⇒ Object
readonly
Returns the value of attribute full_path.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#last_method ⇒ Object
readonly
Returns the value of attribute last_method.
-
#line_no ⇒ Object
readonly
Returns the value of attribute line_no.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#root_path ⇒ Object
readonly
Returns the value of attribute root_path.
Instance Method Summary collapse
- #contains_interpolations? ⇒ Boolean
- #global? ⇒ Boolean
-
#initialize(args) ⇒ TranslationInspector
constructor
A new instance of TranslationInspector.
- #model ⇒ Object
- #relative? ⇒ Boolean
Constructor Details
#initialize(args) ⇒ TranslationInspector
Returns a new instance of TranslationInspector.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/awesome_translations/erb_inspector/translation_inspector.rb', line 4 def initialize(args) @file_path = args[:file_path] @full_path = args[:full_path] @line_no = args[:line_no] @method = args[:method] @key = args[:key] @root_path = args[:root_path] @last_method = args[:last_method] @full_path = "#{@root_path}/#{@file_path}" generate_full_key generate_dir end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
2 3 4 |
# File 'lib/awesome_translations/erb_inspector/translation_inspector.rb', line 2 def dir @dir end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
2 3 4 |
# File 'lib/awesome_translations/erb_inspector/translation_inspector.rb', line 2 def file_path @file_path end |
#full_key ⇒ Object (readonly)
Returns the value of attribute full_key.
2 3 4 |
# File 'lib/awesome_translations/erb_inspector/translation_inspector.rb', line 2 def full_key @full_key end |
#full_path ⇒ Object (readonly)
Returns the value of attribute full_path.
2 3 4 |
# File 'lib/awesome_translations/erb_inspector/translation_inspector.rb', line 2 def full_path @full_path end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
2 3 4 |
# File 'lib/awesome_translations/erb_inspector/translation_inspector.rb', line 2 def key @key end |
#last_method ⇒ Object (readonly)
Returns the value of attribute last_method.
2 3 4 |
# File 'lib/awesome_translations/erb_inspector/translation_inspector.rb', line 2 def last_method @last_method end |
#line_no ⇒ Object (readonly)
Returns the value of attribute line_no.
2 3 4 |
# File 'lib/awesome_translations/erb_inspector/translation_inspector.rb', line 2 def line_no @line_no end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
2 3 4 |
# File 'lib/awesome_translations/erb_inspector/translation_inspector.rb', line 2 def method @method end |
#root_path ⇒ Object (readonly)
Returns the value of attribute root_path.
2 3 4 |
# File 'lib/awesome_translations/erb_inspector/translation_inspector.rb', line 2 def root_path @root_path end |
Instance Method Details
#contains_interpolations? ⇒ Boolean
37 38 39 |
# File 'lib/awesome_translations/erb_inspector/translation_inspector.rb', line 37 def contains_interpolations? key =~ /#\{(.+?)\}/ end |
#global? ⇒ Boolean
29 30 31 |
# File 'lib/awesome_translations/erb_inspector/translation_inspector.rb', line 29 def global? !relative? && key.exclude?(".") end |
#model ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/awesome_translations/erb_inspector/translation_inspector.rb', line 19 def model AwesomeTranslations::Translation.new( key: @full_key, dir: @dir, full_path: @full_path, file_path: @file_path, line_no: @line_no ) end |
#relative? ⇒ Boolean
33 34 35 |
# File 'lib/awesome_translations/erb_inspector/translation_inspector.rb', line 33 def relative? key.start_with?(".") end |