Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple small changes #509

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bin/
build/
target/
.classpath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ public interface StructuralNode extends ContentNode {
List<StructuralNode> findBy(Map<Object, Object> selector);
int getLevel();

/**
* Returns the content model.
*
* @see ContentModel
*
* @return the content model
*/
String getContentModel();

/**
* Returns the source location of this block.
* This information is only available if the {@code sourcemap} option is enabled when loading or rendering the document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ public void setVerticalAlignment(Table.VerticalAlignment valign) {

@Override
public Document getInnerDocument() {
return (Document) NodeConverter.createASTNode(getRubyProperty("inner_document"));
IRubyObject innerDocument = getRubyProperty("inner_document");
if (innerDocument.isNil())
return null;
return (Document) NodeConverter.createASTNode(innerDocument);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested it, but I don't think this will compile.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, though. Why shouldn't it?

Copy link
Member

@robertpanzer robertpanzer Sep 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha! :-)
Could you please add braces around the return null?

I probably automatically put them in there mentally around both returns that have the same indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class StructuralNodeImpl extends ContentNodeImpl implements StructuralNod

private static final String BLOCK_CLASS = "Block";
private static final String SECTION_CLASS = "Section";

public StructuralNodeImpl(IRubyObject blockDelegate) {
super(blockDelegate);
}
Expand Down Expand Up @@ -91,6 +91,11 @@ public Cursor getSourceLocation() {
return new CursorImpl(object);
}

@Override
public String getContentModel() {
return getString("content_model");
}

@Override
public List<String> getSubstitutions() {
return getList("subs", String.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ private static IRubyObject toRubyObject(Ruby rubyRuntime, Object value) {

if (value instanceof List) {
return toRubyArray(rubyRuntime, (List<Object>) value);
} else if (value instanceof Map) {
return convertMapToRubyHashWithStrings(rubyRuntime, (Map<String, Object>) value);
} else {

if (isNotARubySymbol(value)) {
Expand Down