Class: XcodeResultBundleProcessor::SnapshotSummary

Inherits:
Object
  • Object
show all
Defined in:
lib/xcoderesultbundleprocessor/snapshot_summary.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(element_snapshot) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/xcoderesultbundleprocessor/snapshot_summary.rb', line 4

def self.parse(element_snapshot)
  element_class = nil
  if element_snapshot.key?(:additionalAttributes) and element_snapshot[:additionalAttributes].key?(5004.to_s.to_sym)
    element_class = element_snapshot[:additionalAttributes][5004.to_s.to_sym]
  end

  SnapshotSummary.new(
      element_class:    element_class,
      children:         Array(element_snapshot[:children]).map { |child| SnapshotSummary.parse(child) },
      identifier:       element_snapshot[:identifier],
      title:            element_snapshot[:title],
      label:            element_snapshot[:label],
      value:            element_snapshot[:value],
      frame:            element_snapshot[:frame],
      placeholder:      element_snapshot[:placeholder],
      focused?:         !!element_snapshot[:hasFocus],
      keyboardFocused?: !!element_snapshot[:hasKeyboardFocus],
      selected?:        !!element_snapshot[:selected],
      enabled?:         element_snapshot[:enabled] != false,
  )

end

Instance Method Details

#summaryObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/xcoderesultbundleprocessor/snapshot_summary.rb', line 27

def summary
  summary_components = [
      self.element_class || 'UnknownElement',
      self.frame
  ]

  summary_components += [:identifier, :title, :label, :value, :placeholder].map do |attribute|
    unless self[attribute].nil? or self[attribute].empty?
      "#{attribute}=#{self[attribute]}"
    end
  end

  summary_components << 'focused' if self.focused?
  summary_components << 'keyboardFocused' if self.keyboardFocused?
  summary_components << 'selected' if self.selected?
  summary_components << 'disabled' unless self.enabled?

  summary_components.compact.join(' ')
end