Class: Aniview::View::AioMenu

Inherits:
Menu
  • Object
show all
Includes:
Util
Defined in:
lib/aniview/view/aiomenu.rb

Instance Method Summary collapse

Methods included from Util

decode_object, encode_object, error_message, format_duration, format_progress, format_size, parse_format, readline

Methods inherited from Menu

#adjustView, #change_screen_size, #color, #control, #draw, #drawFrom, #expand, #fixCursor, #getLen, #initialize, #moveCursor, #refreshFormats, #resolveSelected, #setFormat, #setName, #setRfunc

Constructor Details

This class inherits a constructor from Aniview::View::Menu

Instance Method Details

#customControl(key, sel) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/aniview/view/aiomenu.rb', line 41

def customControl(key, sel)
  path = @items.values[sel["out"]][sel["in"]].path

   empty = path == "empty"
    
  if key == @pref.get("keybindings")["menu_nav_expand"]
    expand(sel["out"])
  elsif key == "r"
    refresh
  elsif key == "enter" and not empty
    
    @interface.watch(@items.values[sel["out"]][sel["in"]])

    @interface.logWatched(path)

    refresh
  elsif key == @pref.get("keybindings")["anime_set_watched"] and not empty
    @interface.addWatched(path)
    refresh
  elsif key == @pref.get("keybindings")["anime_undo_set_watched"]
    @interface.rmWatched()
    refresh
  elsif key == @pref.get("keybindings")["anime_set_unwatched"] and not empty
    @interface.rmWatched(path)
      
  end
end

#getDurationObject



25
26
27
28
29
30
31
# File 'lib/aniview/view/aiomenu.rb', line 25

def getDuration
  dur = 0
  @items.each{ |child| 
    dur += child[0].attributes["d"]
  }
  return dur
end

#getSizeObject



33
34
35
36
37
38
39
# File 'lib/aniview/view/aiomenu.rb', line 33

def getSize
  size = 0
  @items.each{ |child| 
    size += child[0].attributes["s"]
  }
  return size
end

#refreshObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/aniview/view/aiomenu.rb', line 12

def refresh
  @items = @interface.makeHash @interface.send(@refresh_function)
    
  @attributes = {
    "t" => @attributes["t"],
    "D" => Util.format_duration(getDuration),
    "S" => Util.format_size(getSize)
  }
    
  @expanded = -1 if @items.values[@expanded] == nil
  fixCursor
end

#setmal(malanime) ⇒ Object



8
9
10
# File 'lib/aniview/view/aiomenu.rb', line 8

def setmal malanime
  @malanime = malanime
end