Class: Ykutils::AccountLines
Overview
class AccountLines < BasicLines
Constant Summary collapse
- HOST_ACCOUNT_START =
10
- HOST_ACCOUNT =
11
- HOST_ACCOUNT_END =
12
- DOMAIN_ACCOUNT_START =
20
- DOMAIN_ACCOUNT =
21
- DOMAIN_ACCOUNT_END =
22
- SEPARATOR =
30
- ETC =
100
Instance Method Summary collapse
Methods inherited from Lines
Constructor Details
This class inherits a constructor from Ykutils::Lines
Instance Method Details
#setup ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/ykutils/lines.rb', line 52 def setup while (line = @lines.line) next if line.strip == "" case line when /^---/ case @status when HOST_ACCOUNT_START, HOST_ACCOUNT @line_stack.push({ "STATUS" => HOST_ACCOUNT_END, "CONTENT" => nil }) when DOMAIN_ACCOUNT_START, DOMAIN_ACCOUNT @line_stack.push({ "STATUS" => DOMAIN_ACCOUNT_END, "CONTENT" => nil }) end @line_stack.push({ "STATUS" => SEPARATOR, "CONTENT" => line }) @status = SEPARATOR when /^\s/ case @status when HOST_ACCOUNT_START, HOST_ACCOUNT @line_stack.push({ "STATUS" => HOST_ACCOUNT, "CONTENT" => line }) @status = HOST_ACCOUNT when HOST_ACCOUNT_END puts("error!") puts(line) @line_stack.push({ "STATUS" => HOST_ACCOUNT, "CONTENT" => line }) @status = HOST_ACCOUNT when DOMAIN_ACCOUNT_START, DOMAIN_ACCOUNT @line_stack.push({ "STATUS" => DOMAIN_ACCOUNT, "CONTENT" => line }) @status = DOMAIN_ACCOUNT when DOMAIN_ACCOUNT_END puts("error!") puts(line) @line_stack.push({ "STATUS" => DOMAIN_ACCOUNT, "CONTENT" => line }) @status = DOMAIN_ACCOUNT else @line_stack.push({ "STATUS" => ETC, "CONTENT" => line }) @status = ETC end when /^==/ case @status when HOST_ACCOUNT_START, HOST_ACCOUNT @line_stack.push({ "STATUS" => HOST_ACCOUNT_END, "CONTENT" => nil }) when DOMAIN_ACCOUNT_START, DOMAIN_ACCOUNT @line_stack.push({ "STATUS" => DOMAIN_ACCOUNT_END, "CONTENT" => nil }) end @line_stack.push({ "STATUS" => DOMAIN_ACCOUNT_START, "CONTENT" => line }) @status = DOMAIN_ACCOUNT_START else case @status when HOST_ACCOUNT_START, HOST_ACCOUNT @line_stack.push({ "STATUS" => HOST_ACCOUNT_END, "CONTENT" => nil }) when DOMAIN_ACCOUNT_START, DOMAIN_ACCOUNT @line_stack.push({ "STATUS" => DOMAIN_ACCOUNT_END, "CONTENT" => nil }) end @line_stack.push({ "STATUS" => HOST_ACCOUNT_START, "CONTENT" => line }) @status = HOST_ACCOUNT_START end end i = @line_stack.size - 1 seeking = true while (i >= 0) && seeking case @line_stack[i]["STATUS"] when DOMAIN_ACCOUNT_START, DOMAIN_ACCOUNT @line_stack.push({ "STATUS" => DOMAIN_ACCOUNT_END, "CONTENT" => nil }) seeking = false when HOST_ACCOUNT_START, HOST_ACCOUNT @line_stack.push({ "STATUS" => HOST_ACCOUNT_END, "CONTENT" => nil }) seeking = false when ETC seeking = true else seeking = false end i -= 1 end end |