Class: Juno::User

Inherits:
Object
  • Object
show all
Defined in:
lib/juno/user.rb

Instance Method Summary collapse

Constructor Details

#initialize(root_pathname) ⇒ User

Returns a new instance of User.



10
11
12
# File 'lib/juno/user.rb', line 10

def initialize(root_pathname)
  @root = Pathname.new(root_pathname)
end

Instance Method Details

#all_messagesObject



70
71
72
# File 'lib/juno/user.rb', line 70

def all_messages
  folders.flat_map(&:messages)
end

#contains_duplicate_messages?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/juno/user.rb', line 66

def contains_duplicate_messages?
  @contains_duplicate_messages ||= Set.new(all_messages).count != all_messages.count
end

#foldersObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/juno/user.rb', line 43

def folders
  return @folders if defined? @folders

  director_path = @root.join('director.frm')
  unless director_path.file?
    raise "missing expected director.frm at #{director_path}"
  end

  @folders = []

  @folders = director_path.readlines(encoding: 'ASCII-8BIT').map do |line|
    matchdata = line.match(/^(\S+) (fold\d{4}\.frm)\b/)
    next unless matchdata
    name = matchdata[1]
    name.gsub!('\_', ' ')     # spaces in folder names are represented as '\ '
    name.gsub!('\\\\', '\\')  # backslashes in folder names are represented as '\\'
    filename = matchdata[2]
    Folder.new(name, @root.join(filename))
  end

  @folders.compact!
end

#full_nameObject



23
24
25
# File 'lib/juno/user.rb', line 23

def full_name
  @fullname ||= ini_config['User Profile']['Full name']
end

#juno_versionObject



39
40
41
# File 'lib/juno/user.rb', line 39

def juno_version
  @juno_version ||= ini_config['Configuration']['Juno Version']
end

#last_connectionObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/juno/user.rb', line 27

def last_connection
  return @last_connection if defined? @last_connection

  date = ini_config['History']['Last Connection Time']
  @last_connection = if date.nil? || !date.match(/^\d+\/\d+\/\d+$/)
    nil
  else
    day, month, year = date.split('/').map(&:to_i)
    Date.new(year, month, day)
  end
end

#loginObject



18
19
20
21
# File 'lib/juno/user.rb', line 18

def 
  # ini_config['User Profile']['Login'] contains the same value
  @login ||= ini_config['UserInfo']['User']
end

#path_idObject



14
15
16
# File 'lib/juno/user.rb', line 14

def path_id
  @path_id ||= @root.basename
end