File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,38 @@ def password length=1
51
51
'•' * length
52
52
end
53
53
54
+ # Returns a string of class counts.
55
+ def get_page_class
56
+ r = [ ]
57
+ run_internal = lambda do |node |
58
+ if node . kind_of? Array
59
+ node . each { |node | run_internal . call node }
60
+ return
61
+ end
62
+
63
+ keys = node . keys
64
+ return if keys . empty?
65
+ r . push node [ 'type' ] if keys . include? ( 'type' )
66
+
67
+ run_internal . call node [ 'children' ] if keys . include? ( 'children' )
68
+ end
69
+ json = get_source
70
+ run_internal . call json [ 'children' ]
71
+
72
+ res = [ ]
73
+ r = r . sort
74
+ r . uniq . each do |ele |
75
+ res . push "#{ r . count ( ele ) } x #{ ele } \n "
76
+ end
77
+ count_sort = -> ( one , two ) { two . match ( /(\d +)x/ ) [ 1 ] . to_i <=> one . match ( /(\d +)x/ ) [ 1 ] . to_i }
78
+ res . sort ( &count_sort ) . join ''
79
+ end
80
+
81
+ def page_class
82
+ puts get_page_class
83
+ nil
84
+ end
85
+
54
86
# Returns a string of interesting elements. iOS only.
55
87
#
56
88
# @param element [Object] the element to search. omit to search everything
You can’t perform that action at this time.
0 commit comments