Skip to content

Commit

Permalink
moved private methods to private method section
Browse files Browse the repository at this point in the history
  • Loading branch information
a authored and a committed Jul 26, 2024
1 parent 0e0d201 commit f1e322a
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions app/models/inst_book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,31 +168,6 @@ def extract_av_data_from_rst
av_data
end

private

def extract_metadata_from_line(line)
key, value = line.strip.split(': ', 2)
[key[1..].to_sym, value] if key && value
end

def extract_inlineav_name_from_line(line)
match = line.match(/\.\. inlineav:: (\w+)/)
match[1] if match
end

def extract_avembed_data_from_line(line)
match = line.match(/\.\. avembed:: Exercises\/\w+\/(\w+)\.html/)
match[1] if match
end

# helper method for extract_av_data_from_rst(), safely attempts to parse a JSON string, returning an empty hash as fallback
def parse_json_options(json_str)
return {} if json_str.nil? # Ensures nil input returns an empty hash
JSON.parse(json_str || '{}')
rescue JSON::ParserError
{}
end

# --------------------------------------------------------------------------------

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

private

def extract_metadata_from_line(line)
key, value = line.strip.split(': ', 2)
[key[1..].to_sym, value] if key && value
end

def extract_inlineav_name_from_line(line)
match = line.match(/\.\. inlineav:: (\w+)/)
match[1] if match
end

def extract_avembed_data_from_line(line)
match = line.match(/\.\. avembed:: Exercises\/\w+\/(\w+)\.html/)
match[1] if match
end

# helper method for extract_av_data_from_rst(), safely attempts to parse a JSON string, returning an empty hash as fallback
def parse_json_options(json_str)
return {} if json_str.nil? # Ensures nil input returns an empty hash
JSON.parse(json_str || '{}')
rescue JSON::ParserError
{}
end

end

0 comments on commit f1e322a

Please sign in to comment.