Module: MaimaiNet::Page::TrackHelper

Defined in:
lib/maimai_net/page-html_helper.rb

Instance Method Summary collapse

Instance Method Details

#get_chart_buddy_flag_from(node) ⇒ 0, 1

Returns:

  • (0)

    for non buddy chart

  • (1)

    for buddy chart



118
119
120
# File 'lib/maimai_net/page-html_helper.rb', line 118

def get_chart_buddy_flag_from(node)
  node&.at_css('img[src*="music_utage_buddy.png"]').nil? ? 0 : 1
end

#get_chart_difficulty_from(node) ⇒ Constants::Difficulty

Returns difficulty value of given html element.

Returns:



90
91
92
# File 'lib/maimai_net/page-html_helper.rb', line 90

def get_chart_difficulty_from(node)
  Difficulty(subpath_from(node))
end

#get_chart_level_text_from(node) ⇒ String

Returns normalized difficulty text.

Returns:

  • (String)

    normalized difficulty text



95
96
97
# File 'lib/maimai_net/page-html_helper.rb', line 95

def get_chart_level_text_from(node)
  strip(node).sub(/\?$/, '')
end

#get_chart_type_from(node) ⇒ String, "unknown"

Returns:

  • (String)

    chart type of given html element

  • ("unknown")

    if the chart element is not defined



101
102
103
104
105
# File 'lib/maimai_net/page-html_helper.rb', line 101

def get_chart_type_from(node)
  return -'unknown' if node.nil?

  subpath_from(node)
end

#get_chart_variant_from(node) ⇒ String?

Note:

this is a semantic clarity for strip function.

Returns:

  • (String)

    chart variant of given html element

  • (nil)

    if the chart element is not utage

See Also:

  • HelperBlock#strip


111
112
113
114
# File 'lib/maimai_net/page-html_helper.rb', line 111

def get_chart_variant_from(node)
  node&.at_css('img[src*="music_utage.png"]').nil? ?
    nil : strip(node)
end