Skip to content

Commit f1e322a

Browse files
aa
a
authored and
a
committed
moved private methods to private method section
1 parent 0e0d201 commit f1e322a

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

app/models/inst_book.rb

+25-25
Original file line numberDiff line numberDiff line change
@@ -168,31 +168,6 @@ def extract_av_data_from_rst
168168
av_data
169169
end
170170

171-
private
172-
173-
def extract_metadata_from_line(line)
174-
key, value = line.strip.split(': ', 2)
175-
[key[1..].to_sym, value] if key && value
176-
end
177-
178-
def extract_inlineav_name_from_line(line)
179-
match = line.match(/\.\. inlineav:: (\w+)/)
180-
match[1] if match
181-
end
182-
183-
def extract_avembed_data_from_line(line)
184-
match = line.match(/\.\. avembed:: Exercises\/\w+\/(\w+)\.html/)
185-
match[1] if match
186-
end
187-
188-
# helper method for extract_av_data_from_rst(), safely attempts to parse a JSON string, returning an empty hash as fallback
189-
def parse_json_options(json_str)
190-
return {} if json_str.nil? # Ensures nil input returns an empty hash
191-
JSON.parse(json_str || '{}')
192-
rescue JSON::ParserError
193-
{}
194-
end
195-
196171
# --------------------------------------------------------------------------------
197172

198173
# FIXME: shouldn't this method be removed? It appears to be out-dated?
@@ -326,4 +301,29 @@ def tree_view?
326301
return self.options.include? tree_view
327302
end
328303

304+
private
305+
306+
def extract_metadata_from_line(line)
307+
key, value = line.strip.split(': ', 2)
308+
[key[1..].to_sym, value] if key && value
309+
end
310+
311+
def extract_inlineav_name_from_line(line)
312+
match = line.match(/\.\. inlineav:: (\w+)/)
313+
match[1] if match
314+
end
315+
316+
def extract_avembed_data_from_line(line)
317+
match = line.match(/\.\. avembed:: Exercises\/\w+\/(\w+)\.html/)
318+
match[1] if match
319+
end
320+
321+
# helper method for extract_av_data_from_rst(), safely attempts to parse a JSON string, returning an empty hash as fallback
322+
def parse_json_options(json_str)
323+
return {} if json_str.nil? # Ensures nil input returns an empty hash
324+
JSON.parse(json_str || '{}')
325+
rescue JSON::ParserError
326+
{}
327+
end
328+
329329
end

0 commit comments

Comments
 (0)