Class: PeakFlowUtils::ErbInspector::TranslationInspector

Inherits:
Object
  • Object
show all
Defined in:
app/services/peak_flow_utils/erb_inspector/translation_inspector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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 'app/services/peak_flow_utils/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

#dirObject (readonly)

Returns the value of attribute dir.



2
3
4
# File 'app/services/peak_flow_utils/erb_inspector/translation_inspector.rb', line 2

def dir
  @dir
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



2
3
4
# File 'app/services/peak_flow_utils/erb_inspector/translation_inspector.rb', line 2

def file_path
  @file_path
end

#full_keyObject (readonly)

Returns the value of attribute full_key.



2
3
4
# File 'app/services/peak_flow_utils/erb_inspector/translation_inspector.rb', line 2

def full_key
  @full_key
end

#full_pathObject (readonly)

Returns the value of attribute full_path.



2
3
4
# File 'app/services/peak_flow_utils/erb_inspector/translation_inspector.rb', line 2

def full_path
  @full_path
end

#keyObject (readonly)

Returns the value of attribute key.



2
3
4
# File 'app/services/peak_flow_utils/erb_inspector/translation_inspector.rb', line 2

def key
  @key
end

#last_methodObject (readonly)

Returns the value of attribute last_method.



2
3
4
# File 'app/services/peak_flow_utils/erb_inspector/translation_inspector.rb', line 2

def last_method
  @last_method
end

#line_noObject (readonly)

Returns the value of attribute line_no.



2
3
4
# File 'app/services/peak_flow_utils/erb_inspector/translation_inspector.rb', line 2

def line_no
  @line_no
end

#methodObject (readonly)

Returns the value of attribute method.



2
3
4
# File 'app/services/peak_flow_utils/erb_inspector/translation_inspector.rb', line 2

def method
  @method
end

#root_pathObject (readonly)

Returns the value of attribute root_path.



2
3
4
# File 'app/services/peak_flow_utils/erb_inspector/translation_inspector.rb', line 2

def root_path
  @root_path
end

Instance Method Details

#contains_interpolations?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/services/peak_flow_utils/erb_inspector/translation_inspector.rb', line 37

def contains_interpolations?
  key =~ /#\{(.+?)\}/
end

#global?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/services/peak_flow_utils/erb_inspector/translation_inspector.rb', line 29

def global?
  !relative? && key.exclude?(".")
end

#modelObject



19
20
21
22
23
24
25
26
27
# File 'app/services/peak_flow_utils/erb_inspector/translation_inspector.rb', line 19

def model
  PeakFlowUtils::TranslationService.new(
    key: @full_key,
    dir: @dir,
    full_path: @full_path,
    file_path: @file_path,
    line_no: @line_no
  )
end

#relative?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'app/services/peak_flow_utils/erb_inspector/translation_inspector.rb', line 33

def relative?
  key.start_with?(".")
end