Class: Juno::User
- Inherits:
-
Object
- Object
- Juno::User
- Defined in:
- lib/juno/user.rb
Instance Method Summary collapse
- #all_messages ⇒ Object
- #contains_duplicate_messages? ⇒ Boolean
- #folders ⇒ Object
- #full_name ⇒ Object
-
#initialize(root_pathname) ⇒ User
constructor
A new instance of User.
- #juno_version ⇒ Object
- #last_connection ⇒ Object
- #login ⇒ Object
- #path_id ⇒ Object
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_messages ⇒ Object
70 71 72 |
# File 'lib/juno/user.rb', line 70 def folders.flat_map(&:messages) end |
#contains_duplicate_messages? ⇒ Boolean
66 67 68 |
# File 'lib/juno/user.rb', line 66 def @contains_duplicate_messages ||= Set.new().count != .count end |
#folders ⇒ Object
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_name ⇒ Object
23 24 25 |
# File 'lib/juno/user.rb', line 23 def full_name @fullname ||= ini_config['User Profile']['Full name'] end |
#juno_version ⇒ Object
39 40 41 |
# File 'lib/juno/user.rb', line 39 def juno_version @juno_version ||= ini_config['Configuration']['Juno Version'] end |
#last_connection ⇒ Object
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 |
#login ⇒ Object
18 19 20 21 |
# File 'lib/juno/user.rb', line 18 def login # ini_config['User Profile']['Login'] contains the same value @login ||= ini_config['UserInfo']['User'] end |
#path_id ⇒ Object
14 15 16 |
# File 'lib/juno/user.rb', line 14 def path_id @path_id ||= @root.basename end |